public DriverTestsV2()
 {
     _driver        = DriverFake.Generate();
     _driver.Orders = OrderFake.Generate(3);
     // Используем общую логику сериализации из базового класса
     _jsonString = SerializeObjectToJson(_driver);
 }
        public async Task GetVacantDriversAsync__UrlWasCalledWithValidVerbAndContentType()
        {
            // Arrange
            var drivers = DriverFake.Generate(4);

            _httpTest.RespondWithJson(drivers);
            // Act
            await _restService.GetVacantDriversAsync(_currentDateTime);

            // Assert
            _httpTest.ShouldHaveCalled(_url).WithVerb(HttpMethod.Get);
        }
示例#3
0
        public async Task Should_NotChangeAddressAsync()
        {
            _driverRepository.SaveAsync(Arg.Any <IDriver>())
            .Returns(DriverFake.GetDriver());

            _driverRepository.HasDriverAsync(Arg.Any <string>())
            .Returns(true);

            var response = await _handler.Handle(GetRequest(), CancellationToken.None);

            Assert.True(response.HasMessages);
        }
示例#4
0
        public void Get__DriverExistsInStorage__ReturnThisDriver_V2()
        {
            // Arrange
            var driver   = DriverFake.Generate();
            var driverId = _driverTestRepository.Create(_dbExecutor, driver);
            // Act
            var foundDriver = _query.Get(driverId);

            // Assert
            Assert.NotNull(foundDriver);
            Assert.Equal(driver.Phone, foundDriver.Phone);
            Assert.Equal(driver.FullName, foundDriver.FullName);
        }
        public async Task GetVacantDriversAsync__ReturnValidVacantDrivers()
        {
            // Arrange
            var drivers = DriverFake.Generate(4);

            _httpTest.RespondWithJson(drivers);
            // Act
            var vacantDrivers = await _restService.GetVacantDriversAsync(_currentDateTime);

            // Assert
            Assert.Equal(drivers.Count, vacantDrivers.Count);
            Assert.All(vacantDrivers, driver => drivers.Exists(e => e.Id == driver.Id));
            Assert.True(vacantDrivers.All(e => drivers.Exists(driver => driver.Id == e.Id)));
        }
        public async Task Should_GetVehicleAsync()
        {
            _driverRepository.GetSearchAsync(Arg.Any <IDriver>())
            .Returns(new IDriver[]
            {
                DriverFake.GetDriver(),
                DriverFake.GetDriver()
            });

            var response = await _handler.Handle(GetRequest(), CancellationToken.None);

            Assert.False(response.HasMessages);
            Assert.NotNull(response.Value);
            var result = (IEnumerable <IDriver>)response.Value;

            Assert.True(result.Any());
        }
示例#7
0
        public void Get__DriverExistsInStorage__ReturnThisDriver_V1()
        {
            // Arrange
            var driver          = DriverFake.Generate();
            var insertDriverSql = $@"
insert into Drivers(FullName, Phone)
values (""{driver.FullName}"", ""{driver.Phone}"");

select last_insert_rowid();
";
            var driverId        = _dbExecutor.Query <int>(insertDriverSql).First();
            // Act
            var foundDriver = _query.Get(driverId);

            // Assert
            Assert.NotNull(foundDriver);
            Assert.Equal(driver.Phone, foundDriver.Phone);
            Assert.Equal(driver.FullName, foundDriver.FullName);
        }
 public DriverTests()
 {
     _driver        = DriverFake.Generate();
     _driver.Orders = OrderFake.Generate(3);
     _jsonString    = JsonConvert.SerializeObject(_driver);
 }