예제 #1
0
        public void AddService_Should_Throw_ArgumentNullException_When_Service_Is_Null()
        {
            // Arrange
            var dog = new Dog("name", AnimalGenderType.female, "breed", 1);

            // Act & Assert
            Assert.ThrowsException <ArgumentNullException>(() => dog.AddServices(null));
        }
예제 #2
0
        public void AddService_Should_Add_Service_To_ListOfServices()
        {
            // Arrange
            var service = new Mock <IService>().Object;
            var dog     = new Dog("name", AnimalGenderType.female, "breed", 1);

            // Act
            dog.AddServices(service);

            // Assert
            Assert.IsTrue(dog.Services.Contains(service));
        }
예제 #3
0
        public void ListAnimalServices_Should_Return_Correct_Value()
        {
            // Arrange
            var service = new Mock <IService>();

            service.Setup(x => x.Name).Returns("ServiceName");
            var dog = new Dog("name", AnimalGenderType.female, "breed", 1);

            dog.AddServices(service.Object);

            var sb = new StringBuilder();

            sb.AppendLine("All services: ");
            sb.AppendLine($"Service: ServiceName");
            string expected = sb.ToString();

            // Act
            string actual = dog.ListAnimalServices();

            // Assert
            Assert.AreEqual(expected, actual);
        }