Esempio n. 1
0
        public void InstantiatesCorrectly_WhenAllDependenciesAreNotNull_AndIsInstanceOfIRimsService()
        {
            var mockedRimsRepo     = new Mock <IDbRepository <Rim> >();
            var mockedUsersService = new Mock <IUsersService>();
            var mockedUow          = new Mock <IUnitOfWork>();

            var service = new RimsService(mockedRimsRepo.Object, mockedUsersService.Object, mockedUow.Object);

            Assert.That(service, Is.InstanceOf <IRimsService>());
        }
Esempio n. 2
0
        public void CallTheRimsRepoGetByIdMethodOnce()
        {
            //Arrange
            var mockedRimsRepo     = new Mock <IDbRepository <Rim> >();
            var mockedUsersService = new Mock <IUsersService>();
            var mockedUow          = new Mock <IUnitOfWork>();

            mockedRimsRepo.Setup(x => x.GetById(It.IsAny <object>())).Returns(new Rim());
            var service = new RimsService(mockedRimsRepo.Object, mockedUsersService.Object, mockedUow.Object);

            //act
            service.GetById(1);

            //assert
            mockedRimsRepo.Verify(x => x.GetById(It.IsAny <object>()), Times.Once);
        }
Esempio n. 3
0
        public void CallTheRimsRepoAllMethodOnce()
        {
            //Arrange
            var mockedRimsRepo     = new Mock <IDbRepository <Rim> >();
            var mockedUsersService = new Mock <IUsersService>();
            var mockedUow          = new Mock <IUnitOfWork>();
            var rims = new List <Rim> {
                new Rim()
            };

            mockedRimsRepo.Setup(x => x.All()).Returns(rims.AsQueryable());
            var service = new RimsService(mockedRimsRepo.Object, mockedUsersService.Object, mockedUow.Object);

            //act
            service.GetNextFive(new RimsSearchModel(), 2);

            //assert
            mockedRimsRepo.Verify(x => x.All(), Times.Once);
        }
Esempio n. 4
0
        public void CallTheUowCommitMethodOnce()
        {
            //Arrange
            var mockedRimsRepo     = new Mock <IDbRepository <Rim> >();
            var mockedUsersService = new Mock <IUsersService>();
            var mockedUow          = new Mock <IUnitOfWork>();

            mockedRimsRepo.Setup(x => x.GetById(It.IsAny <object>())).Returns(new Rim());
            mockedUsersService.Setup(x => x.GetById(It.IsAny <string>())).Returns(new User());
            var mockedRim = new Mock <Rim>();
            var pics      = new List <RimPicture>();

            mockedRim.Setup(x => x.Pictures).Returns(pics);
            var service = new RimsService(mockedRimsRepo.Object, mockedUsersService.Object, mockedUow.Object);

            //act
            service.AddNewTireAd("", mockedRim.Object, new List <string> {
                "gosho"
            });

            //assert
            mockedUow.Verify(x => x.Commit(), Times.Once);
        }