Example #1
0
        public async Task CreateLoadAsyncTest_WithNullModelPropery_ShouldReturnArgumentNullException()
        {
            var          context = SteuDbContextInMemoryFactory.InitializeContext();
            LoadsService service = IntializeLoadService(context);

            AddLoadInputModel model = new AddLoadInputModel()
            {
                CountryFrom      = null,
                TownFrom         = "Sofia",
                CountryTo        = "Croatia",
                TownTo           = "Zagreb",
                TruckTypeName    = "Normal",
                SteuUserId       = "asdasd",
                Priority         = "Normal",
                Circle           = false,
                ExpireTime       = DateTime.UtcNow,
                InputModel       = new LoadCreateViewModel(),
                LoadDeliveryTime = DateTime.UtcNow,
                LoadTime         = DateTime.UtcNow,
                LoadVolume       = 100,
                LoadWeight       = 20000,
                Price            = 12312231,
                Referer          = "dasada",
            };

            await Assert.ThrowsAsync <ArgumentNullException>(() => service.CreateLoadAsync(model, "asdasd"));
        }
Example #2
0
        public async Task CreateLoadAsyncTest_WithCorrectData_ShouldReturnLoad()
        {
            var          context    = SteuDbContextInMemoryFactory.InitializeContext();
            LoadsService service    = IntializeLoadService(context);
            var          repository = new EfDeletableEntityRepository <Order>(context);

            AddLoadInputModel model = new AddLoadInputModel()
            {
                CountryFrom      = "Bulgaria",
                TownFrom         = "Sofia",
                CountryTo        = "Croatia",
                TownTo           = "Zagreb",
                TruckTypeName    = "Normal",
                SteuUserId       = "asdasd",
                Priority         = "Normal",
                Circle           = false,
                ExpireTime       = DateTime.UtcNow,
                InputModel       = new LoadCreateViewModel(),
                LoadDeliveryTime = DateTime.UtcNow,
                LoadTime         = DateTime.UtcNow,
                LoadVolume       = 100,
                LoadWeight       = 20000,
                Price            = 12312231,
                Referer          = "dasada",
            };

            await service.CreateLoadAsync(model, "asdasd");

            var actualResult = await repository.All().ToListAsync();

            Assert.Single(actualResult);
        }