Esempio n. 1
0
        public void UpdateMealType_Should_Return_Valid_Data()
        {
            //Arrange
            var mock       = new Mock <IMealTypeRepository>();
            var myMealType = new MealTypeDTO
            {
                Id         = 1,
                Name       = "Starter",
                Restaurant = new RestoDTO()
            };

            mock.Setup(x => x.Update(myMealType)).Returns(
                new MealTypeDTO
            {
                Id         = 1,
                Name       = "Starter",
                Restaurant = new RestoDTO()
            }
                );
            MealTypeUC target = new MealTypeUC(mock.Object);

            //Act
            var result = target.UpdateMealType(new MealTypeBTO
            {
                Id         = 1,
                Name       = "Starter",
                Restaurant = new RestoBTO()
            });

            //Assert
            mock.Verify(u => u.Update(It.IsAny <MealTypeDTO>()), Times.Once());
        }
Esempio n. 2
0
        public void UpdateMealType_Should_Return_Null_If_No_Result_Found_In_Db()
        {
            //Arrange
            var mock       = new Mock <IMealTypeRepository>();
            var myMealType = new MealTypeDTO
            {
                Id         = 1,
                Name       = "Starter",
                Restaurant = new RestoDTO()
            };

            mock.Setup(x => x.Update(myMealType));
            MealTypeUC target = new MealTypeUC(mock.Object);

            //Act
            var result = target.UpdateMealType(new MealTypeBTO
            {
                Id         = 1,
                Name       = "Starter",
                Restaurant = new RestoBTO()
            });

            //Assert
            Assert.IsNull(result);
        }
        public void CreateMealType_Should_Return_Null_If_Dto_Is_Null()
        {
            //Arrange
            var mock       = new Mock <IMealTypeRepository>();
            var myMealType = new MealTypeDTO
            {
                Id         = 1,
                Name       = "Starter",
                Restaurant = new RestoDTO()
            };

            mock.Setup(x => x.Create(myMealType)).Returns(
                new MealTypeDTO
            {
                Id         = 1,
                Name       = "Starter",
                Restaurant = new RestoDTO()
            }
                );

            MealTypeUC target = new MealTypeUC(mock.Object);

            //Act
            var result = target.AddMealType(null);

            //Assert
            Assert.IsNull(result);
        }
Esempio n. 4
0
        public void GetAllMealTypesByRestaurantId_Should_Return_Proper_Collection()
        {
            //Arrange
            var mock        = new Mock <IMealTypeRepository>();
            var myMealTypes = new List <MealTypeDTO>
            {
                new MealTypeDTO
                {
                    Id         = 1,
                    Name       = "Starter",
                    Restaurant = new RestoDTO()
                },
                new MealTypeDTO
                {
                    Id         = 2,
                    Name       = "Main",
                    Restaurant = new RestoDTO()
                    {
                        Id = 35
                    }
                }
            };

            mock.Setup(x => x.GetMealTypesByRestoId(35)).Returns(myMealTypes);
            MealTypeUC target = new MealTypeUC(mock.Object);

            //Act
            var result = target.GetAllMealTypesByRestaurantId(35).ToList();

            //Assert
            Assert.AreEqual(result.Count, 2);
            Assert.AreEqual(result[0].Id, 1);
            Assert.AreEqual(result[1].Name, "Main");
        }
Esempio n. 5
0
        public void GetMealTypeById_Should_Return_Valid_Data()
        {
            //Arrange
            var mock       = new Mock <IMealTypeRepository>();
            var myMealType = new MealTypeDTO
            {
                Id         = 1,
                Name       = "Starter",
                Restaurant = new RestoDTO()
            };

            mock.Setup(x => x.GetById(1)).Returns(
                new MealTypeDTO
            {
                Id         = 1,
                Name       = "Starter",
                Restaurant = new RestoDTO()
            }
                );

            MealTypeUC target = new MealTypeUC(mock.Object);

            //Act
            var result = target.GetMealTypeById(1);

            //Assert
            Assert.AreEqual(result.Id, 1);
            Assert.AreEqual(result.Name, "Starter");
        }
Esempio n. 6
0
        public void GetAllMealTypesByRestaurantId_Should_Return_Null_When_Not_Found()
        {
            //Arrange
            var mock        = new Mock <IMealTypeRepository>();
            var myMealTypes = new List <MealTypeDTO>
            {
                new MealTypeDTO
                {
                    Id         = 1,
                    Name       = "Starter",
                    Restaurant = new RestoDTO()
                },
                new MealTypeDTO
                {
                    Id         = 2,
                    Name       = "Main",
                    Restaurant = new RestoDTO()
                    {
                        Id = 35
                    }
                }
            };

            mock.Setup(x => x.GetMealTypesByRestoId(35));
            MealTypeUC target = new MealTypeUC(mock.Object);

            //Act
            var result = target.GetAllMealTypesByRestaurantId(35);

            //Assert
            Assert.IsNull(result);
        }
Esempio n. 7
0
 public BasketController(IBasketRepository BasketRepository,
                         IMealRepository MealRepository,
                         IMealTypeRepository MealTypeRepository,
                         IRestoRepository RestoRepository, IEmailSender emailSender)
 {
     basketRepository   = BasketRepository;
     mealRepository     = MealRepository;
     mealTypeRepository = MealTypeRepository;
     restoRepository    = RestoRepository;
     _emailSender       = emailSender;
     mealUC             = new MealUC(mealRepository);
     mealTypeUC         = new MealTypeUC(mealTypeRepository);
     basketUC           = new BasketUC(basketRepository);
 }
Esempio n. 8
0
        public void GetMealTypeById_Should_Return_Null_When_Not_Found()
        {
            //Arrange
            var mock = new Mock <IMealTypeRepository>();

            mock.Setup(x => x.GetById(25));
            MealTypeUC target = new MealTypeUC(mock.Object);

            //Act
            var result = target.GetMealTypeById(25);

            //Assert
            Assert.AreEqual(null, result);
            Assert.IsNull(result);
        }
Esempio n. 9
0
        public void DeleteMealType_Should_Work()
        {
            //Arrange
            var mock       = new Mock <IMealTypeRepository>();
            var myMealType = new MealTypeDTO
            {
                Id         = 1,
                Name       = "Starter",
                Restaurant = new RestoDTO()
            };

            mock.Setup(x => x.Delete(1));
            MealTypeUC target = new MealTypeUC(mock.Object);

            //Act
            target.DeleteMealType(1);

            //Assert
            mock.Verify(u => u.Delete(It.IsAny <int>()), Times.Once());
        }
 public MealTypeController(IMealTypeRepository MealTypeRepository)
 {
     mealTypeRepository = MealTypeRepository;
     mealTypeUC         = new MealTypeUC(mealTypeRepository);
 }