61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using NUnit.Framework;
|
|
using CandyHouseBase.DataModels;
|
|
using CandyHouseBase.Exceptions;
|
|
|
|
namespace CandyHouseTests.DataModelsTests
|
|
{
|
|
[TestFixture]
|
|
public class PekarDataModelTests
|
|
{
|
|
[Test]
|
|
public void CreatePekarDataModel_ValidData_ShouldCreateSuccessfully()
|
|
{
|
|
var id = Guid.NewGuid().ToString();
|
|
var name = "John Doe";
|
|
var experience = Guid.NewGuid().ToString();
|
|
|
|
var pekar = new PekarDataModel(id, name, experience, 0, new List<ProductDataModel>());
|
|
|
|
Assert.AreEqual(id, pekar.Id);
|
|
Assert.AreEqual(name, pekar.FIO);
|
|
Assert.AreEqual(experience, pekar.Position);
|
|
}
|
|
|
|
[Test]
|
|
public void Validate_ValidData_ShouldNotThrowException()
|
|
{
|
|
var pekar = new PekarDataModel(Guid.NewGuid().ToString(), "John Doe", Guid.NewGuid().ToString(), 6,
|
|
new List<ProductDataModel>());
|
|
|
|
Assert.DoesNotThrow(() => pekar.Validate());
|
|
}
|
|
|
|
[Test]
|
|
public void Validate_InvalidId_ShouldThrowValidationException()
|
|
{
|
|
var pekar = new PekarDataModel("", "John Doe", Guid.NewGuid().ToString(), 0, new List<ProductDataModel>());
|
|
|
|
Assert.Throws<ValidationException>(() => pekar.Validate());
|
|
}
|
|
|
|
[Test]
|
|
public void Validate_InvalidName_ShouldThrowValidationException()
|
|
{
|
|
var pekar = new PekarDataModel(Guid.NewGuid().ToString(), "", Guid.NewGuid().ToString(), 0,
|
|
new List<ProductDataModel>());
|
|
|
|
Assert.Throws<ValidationException>(() => pekar.Validate());
|
|
}
|
|
|
|
[Test]
|
|
public void Validate_NegativeExperience_ShouldThrowValidationException()
|
|
{
|
|
var pekar = new PekarDataModel(Guid.NewGuid().ToString(), "John Doe", "some-invalidate", 0,
|
|
new List<ProductDataModel>());
|
|
|
|
Assert.Throws<ValidationException>(() => pekar.Validate());
|
|
}
|
|
}
|
|
} |