Exemplo n.º 1
0
        public void TestUpdateAsync()
        {
            AutoMapperConfiguration.Config();

            var countryRepository = new Mock <IRepository <Country> >();
            var mockService       = new Mock <IUnitOfWork>();

            var dbSet = new FakeDbSet <Country>();

            dbSet.AddRange(FakeCountries.FakeDataCountries());

            countryRepository.Setup(x => x.FindByAsync(1))
            .Returns(dbSet.FindAsync(new CancellationToken(false), 1));

            var countryDto = FakeCountries.FakeDataCountriesDto(hasKiosks: false).FirstOrDefault();

            mockService.Setup(x => x.Countries).Returns(countryRepository.Object);

            mockService.Setup(x => x.CommitAsync()).Returns(Task.FromResult(0)).Verifiable();

            //var countryService = new CountryService(mockService.Object);

            //var subsites = countryService.UpdateAsync(countryDto).Result;

            //mockService.Verify(x => x.CommitAsync(), Times.Once);
        }
Exemplo n.º 2
0
        public void Test()
        {
            AutoMapperConfiguration.Config();

            var instance = GetMockedContainer();

            var services = instance.Get <ICountryService>();

            var countryDto = FakeCountries.FakeDataCountriesDto(hasKiosks: false).FirstOrDefault();

            var result = AsyncHelper.RunSync(() => services.CreateAsync(countryDto));

            Assert.IsNotNull(result);
        }
Exemplo n.º 3
0
        public void TestCreateAsync()
        {
            AutoMapperConfiguration.Config();

            var countryRepository = new Mock <IRepository <Country> >();
            var mockService       = new Mock <IUnitOfWork>();

            var countryDto = FakeCountries.FakeDataCountriesDto(hasKiosks: false).FirstOrDefault();

            mockService.Setup(x => x.Countries).Returns(countryRepository.Object);
            mockService.Setup(x => x.CommitAsync()).Returns(Task.FromResult(0)).Verifiable();
            //var countryService = new CountryService(mockService.Object);
            //var subsites = countryService.CreateAsync(countryDto).Result;
            //mockService.Verify(x => x.CommitAsync(), Times.Once);
        }
Exemplo n.º 4
0
        public void TestFindAllAsync()
        {
            AutoMapperConfiguration.Config();

            var dbSet = new FakeDbSet <Country>();

            dbSet.AddRange(FakeCountries.FakeDataCountries());

            var countryRepository = new Mock <IRepository <Country> >();
            var mockService       = new Mock <IUnitOfWork>();

            mockService.Setup(x => x.Countries).Returns(countryRepository.Object);
            mockService.Setup(x => x.Countries.FindAll(null)).Returns(dbSet);

            //var countryService = new CountryService(mockService.Object);
            //var subsites = countryService.FindAllAsync().Result;
        }