Example #1
0
        public void ReturnCorrectResult()
        {
            //Arrange
            var mockedRegion = new Mock <Region>();
            var list         = new List <Region> {
                mockedRegion.Object
            };
            var regionsRepoMock = new Mock <IEntityFrameworkRepository <Region> >();

            regionsRepoMock.Setup(x => x.All).Verifiable();
            regionsRepoMock.Setup(x => x.All).Returns(list.AsQueryable());
            var dataMock = new Mock <IShishaTimeData>();

            dataMock.Setup(x => x.Regions).Verifiable();
            dataMock.Setup(x => x.Regions).Returns(regionsRepoMock.Object);
            var regionsService = new RegionsService(dataMock.Object);

            //Act
            var regions = regionsService.GetAllRegions();

            //Assert
            Assert.AreEqual(list, regions);
        }
Example #2
0
        public void CallRegionsRepository_AllProperty()
        {
            //Arrange
            var mockedRegion = new Mock <Region>();
            var list         = new List <Region> {
                mockedRegion.Object
            };
            var regionsRepoMock = new Mock <IEntityFrameworkRepository <Region> >();

            regionsRepoMock.Setup(x => x.All).Verifiable();
            regionsRepoMock.Setup(x => x.All).Returns(list.AsQueryable());
            var dataMock = new Mock <IShishaTimeData>();

            dataMock.Setup(x => x.Regions).Verifiable();
            dataMock.Setup(x => x.Regions).Returns(regionsRepoMock.Object);
            var regionsService = new RegionsService(dataMock.Object);

            //Act
            regionsService.GetAllRegions();

            //Assert
            regionsRepoMock.Verify(x => x.All, Times.Once());
        }