Beispiel #1
0
        public async void CreateGarage()
        {
            var commonId = 1;
            var suite    = new GarageServiceTestSuite();

            var cityId      = commonId++;
            var addressId   = commonId++;
            var pricelistId = commonId++;

            suite.CityServiceMock
            .Setup(m => m.IsExist(cityId))
            .ReturnsAsync(true);

            suite.AddressServiceMock
            .Setup(m => m.IsExist(addressId))
            .ReturnsAsync(true);

            suite.PricelistServiceMock
            .Setup(m => m.IsExist(pricelistId))
            .ReturnsAsync(true);

            var result = await suite.GarageService.Create(cityId, addressId, pricelistId);

            suite.GarageRepositoryMock
            .Verify(m => m.Add(It.Is <Garage>(
                                   g => g.CityId.Equals(cityId) &&
                                   g.AddressId.Equals(addressId) &&
                                   g.PricelistId.Equals(pricelistId))));
            suite.GarageRepositoryMock
            .Verify(m => m.Save());

            Assert.Equal(cityId, result.CityId);
            Assert.Equal(addressId, result.AddressId);
            Assert.Equal(pricelistId, result.PricelistId);
        }
Beispiel #2
0
        public async Task GetAvailableProvince()
        {
            var suite        = new GarageServiceTestSuite();
            var country      = "Россия";
            var addressKind  = AddressKind.Garage;
            var orderingKind = OrderingKind.Asc;

            var result = await suite.GarageService.GetAvailableProvinces(country);

            suite.AddressServiceMock
            .Verify(m => m.GetProvinces(addressKind, country, orderingKind), Times.Once);
        }
Beispiel #3
0
        public async Task GetAvailableLocalities()
        {
            var suite        = new GarageServiceTestSuite();
            var country      = "Россия";
            var province     = "Ярославская область";
            var addressKind  = AddressKind.Garage;
            var orderingKind = OrderingKind.Asc;

            var result = await suite.GarageService.GetAvailableLocalities(country, province);

            suite.AddressServiceMock
            .Verify(m => m.GetLocalities(addressKind, country, province, orderingKind), Times.Once);
        }