コード例 #1
0
        public void Invoke_TheDataDailyMenusRepositoryMethodGetAll_Once()
        {
            //Arrange
            var dataMock           = new Mock <IHomeMadeFoodData>();
            var recipesServiceMock = new Mock <IRecipesService>();
            DailyMenuService        dailyMenuService         = new DailyMenuService(dataMock.Object, recipesServiceMock.Object);
            IEnumerable <DailyMenu> expectedResultCollection = new List <DailyMenu>();

            dataMock.Setup(x => x.DailyMenus.All).Returns(() => {
                return(expectedResultCollection.AsQueryable());
            });

            //Act
            IEnumerable <DailyMenu> dailyMenus = dailyMenuService.GetAllDailyMenus();

            //Assert
            dataMock.Verify(x => x.DailyMenus.All, Times.Once);
        }
コード例 #2
0
        public void ReturnNull_WhenDataDailyMenusReposityMethodGetAll_ReturnsNull()
        {
            //Arrange
            var dataMock           = new Mock <IHomeMadeFoodData>();
            var recipesServiceMock = new Mock <IRecipesService>();

            dataMock.Setup(c => c.DailyMenus.All).Returns(() =>
            {
                return(null);
            });

            DailyMenuService dailyMenuServce = new DailyMenuService(dataMock.Object, recipesServiceMock.Object);

            //Act
            IEnumerable <DailyMenu> dailyMenusResult = dailyMenuServce.GetAllDailyMenus();

            //Assert
            Assert.IsNull(dailyMenusResult);
        }
コード例 #3
0
        public void ReturnResultOfCorrectTypeIEnumerableOfDailyMenu()
        {
            //Arrange
            var dataMock           = new Mock <IHomeMadeFoodData>();
            var recipesServiceMock = new Mock <IRecipesService>();

            dataMock.Setup(c => c.DailyMenus.All).Returns(() =>
            {
                IEnumerable <DailyMenu> expectedResultCollection = new List <DailyMenu>();
                return(expectedResultCollection.AsQueryable());
            });

            DailyMenuService dailyMenuService = new DailyMenuService(dataMock.Object, recipesServiceMock.Object);

            //Act
            IEnumerable <DailyMenu> dailyMenuResult = dailyMenuService.GetAllDailyMenus();

            //Assert
            Assert.That(dailyMenuResult, Is.InstanceOf <IEnumerable <DailyMenu> >());
        }
コード例 #4
0
        public void ReturnResult_WhenInvokingDataDailyMenusRepositoryMethod_GetAll()
        {
            //Arrange
            var dataMock = new Mock <IHomeMadeFoodData>();
            IEnumerable <DailyMenu> expectedResultCollection = new List <DailyMenu>();
            var recipesServiceMock = new Mock <IRecipesService>();

            dataMock.Setup(c => c.DailyMenus.All).Returns(() =>
            {
                return(expectedResultCollection.AsQueryable());
            });

            DailyMenuService dailyMenuService = new DailyMenuService(dataMock.Object, recipesServiceMock.Object);

            //Act
            IEnumerable <DailyMenu> dailyMenuResult = dailyMenuService.GetAllDailyMenus();

            //Assert
            Assert.That(dailyMenuResult, Is.EqualTo(expectedResultCollection));
        }