Beispiel #1
0
        public void ReturnTheResultFromRepositoriesAsIEnumerable_WhenMathodIsCalled()
        {
            // arrange
            var repository = new Mock <IEfRepository <DataModel> >();

            var modelsList = new List <DataModel>()
            {
                new DataModel()
                {
                    IsDeleted = false
                },
                new DataModel()
                {
                    IsDeleted = true
                },
            };

            repository.Setup(r => r.All).Returns(modelsList.AsQueryable());

            var dataService = new FakeDateService <DataModel>(repository.Object);

            // act
            var returnedResult = dataService.GetAll();

            // assert
            Assert.AreEqual(returnedResult.Count(), modelsList.Count);
            Assert.AreEqual(returnedResult.First().IsDeleted, modelsList[0].IsDeleted);
            Assert.AreEqual(returnedResult.Skip(1).First().IsDeleted, modelsList[1].IsDeleted);
        }
Beispiel #2
0
        public void SetDatePropertyCorrectly_WhenMethodIsCalled()
        {
            // arrange
            var repository = new Mock <IEfRepository <DataModel> >();

            repository.Setup(r => r.All).Returns(new List <DataModel>().AsQueryable());

            var dataService = new FakeDateService <DataModel>(repository.Object);

            // act
            dataService.GetAll();

            // assert
            repository.Verify(r => r.All, Times.Once);
        }