public void Create_WhenGivenValidArguments_ShouldReturnNewLaboratoryWithGivenArguments() { //Arrange var teacher = Teacher.Create("Florin", "Olariu", "*****@*****.**", "parolagrea"); var subject = Subject.Create(teacher, "Introducere in .NET"); //Act var laboratory = Laboratory.Create("Laborator .NET", "A2", teacher, "Wednesday", 10, 12, subject); //Assert Assert.AreEqual("Laborator .NET", laboratory.Name); }
public void Update_WhenGivenValidArguments_ShouldUpdateExistingLaboratory() { //Arrange var teacher = Teacher.Create("Florin", "Olariu", "*****@*****.**", "parolagrea"); var subject = Subject.Create(teacher, "Introducere in .NET"); var laboratory = Laboratory.Create("Laborator .NET", "A2", teacher, "Wednesday", 10, 12, subject); //Act laboratory.Update(laboratory.Name, laboratory.Group, laboratory.Teacher, "Friday", laboratory.StartHour, laboratory.EndHour); //Assert Assert.AreEqual("Friday", laboratory.Weekday); }
static void Main(string[] args) { while (true) { var userInput = Console.ReadLine(); var userInputSplited = userInput.Split(CommonConstants.Whitespace); var command = userInputSplited.First(); var commandFirstParameter = userInputSplited.Length > 1 ? userInputSplited[1] : String.Empty; var commandSecondParameter = userInputSplited.Length > 2 ? userInputSplited[2] : String.Empty; switch (command) { case CliCommands.CreateCommand: var animalType = CommandParser.GetAnimalTypeFromParameter(commandFirstParameter); Lab.Create(animalType, commandSecondParameter); break; case CliCommands.GoToSleepCommand: Lab.GoToSleep(commandFirstParameter); break; case CliCommands.GoEatCommand: Lab.GoEat(commandFirstParameter); break; case CliCommands.BarkerCommand: Lab.Barker(commandFirstParameter); break; case CliCommands.PurrerCommand: Lab.Purrer(commandFirstParameter); break; case CliCommands.SqueakerCommand: Lab.Squeaker(commandFirstParameter); break; case CliCommands.ListCommand: Lab.ListAnimals(); break; case CliCommands.DeleteCommand: Lab.Delete(commandFirstParameter); break; default: Cli.DisplayError("Unknown command"); break; } } }
public void ShouldCreateAnimalWithGivenNameAndType() { //Given StubCommandInterface stubbedCli = new StubCommandInterface(); Laboratory laboratory = new Laboratory(stubbedCli); AnimalTypeEnum testType = AnimalTypeEnum.Cat; string testName = "Tom"; string expectedInfo = $"Created {testType} with name {testName}."; //When laboratory.Create(testType, testName); //Then Assert.That(stubbedCli.InfoMessages, Does.Contain(expectedInfo)); }
public void ShouldDisplayErrorWhenDogIsNotFedOrRestedButSentToBarker() { //Given StubCommandInterface stubbedCli = new StubCommandInterface(); Laboratory laboratory = new Laboratory(stubbedCli); AnimalTypeEnum testType = AnimalTypeEnum.Dog; string testName = "Rex"; laboratory.Create(AnimalTypeEnum.Dog, testName); //When laboratory.Barker(testName); //Then Assert.That(stubbedCli.ErrorsMessages.Count, Is.EqualTo(1)); Assert.That(stubbedCli.BarksMessages, Does.Not.Contain(testName)); }
public void ShouldSendDogToBarkerIfFedAndRested() { //Given StubCommandInterface stubbedCli = new StubCommandInterface(); Laboratory laboratory = new Laboratory(stubbedCli); AnimalTypeEnum testType = AnimalTypeEnum.Dog; string testName = "Rex"; laboratory.Create(AnimalTypeEnum.Dog, testName); laboratory.GoEat(testName); laboratory.GoToSleep(testName); //When laboratory.Barker(testName); //Then Assert.That(stubbedCli.BarksMessages, Does.Contain(testName)); }