Beispiel #1
0
        public void AddService_Should_Throw_ArgumentNullException_When_Service_Is_Null()
        {
            // Arrange
            var cat = new Cat("name", AnimalGenderType.male, 1);

            // Act & Assert
            Assert.ThrowsException <ArgumentNullException>(() => cat.AddServices(null));
        }
Beispiel #2
0
        public void AddService_Should_Add_Service_To_ListOfServices()
        {
            // Arrange
            var service = new Mock <IService>().Object;
            var cat     = new Cat("name", AnimalGenderType.male, 1);

            // Act
            cat.AddServices(service);

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

            service.Setup(x => x.Name).Returns("ServiceName");
            var cat = new Cat("name", AnimalGenderType.male, 1);

            cat.AddServices(service.Object);

            var sb = new StringBuilder();

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

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

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