Exemple #1
0
        public async Task CreationRangeDate_BasicTest()
        {
            var carList = TestCarsCatalog.GetCars();

            var dbCreation = await carService.CreateRangeAsync(carList);

            dbCreation.Should().Match(x => x.All(y => y.Entity.CreationDate.HasValue));
        }
Exemple #2
0
        public RangeOperation_Tests()
        {
            carService = Resolve <ICarService>();
            var t = Resolve <CarCatalogContext>();

            t.Database.EnsureCreated();

            carList = TestCarsCatalog.GetCars();
        }
        public async Task CreateAndGet_ListWith2LevelMappingTest()
        {
            var newCars = TestCarsCatalog.GetCars();

            newCars.ForEach(async x => await carService.CreateAsync(x));

            var getResult = await brandService.QueryWithProjectionAsync <SmallBrandInfo>(new BaseBrandQuery());

            getResult.Results.Should().OnlyContain(x => x.Name != null && x.Cars != null && x.Cars.Select(x => x.Name).Count() >= 1);
        }
Exemple #4
0
        public async Task GenericQueryCommand_BasicTest()
        {
            var carService = Resolve <ICarService>();
            CommandResult <Car> newCarResult = await carService.CreateAsync(TestCarsCatalog.GetCars().First());

            newCarResult.Result.Should().Be(CommandState.Success);

            QueryResult <Car> result = await _mediator.Send(new GenericQueryCommand <Car>(new BaseCarQuery()
            {
                ID = newCarResult.Entity.Id
            }));

            result.Results.Count.Should().Be(1);
        }
Exemple #5
0
        public async Task GenericCreateCommand_BasicTest()
        {
            Car car = TestCarsCatalog.GetCars().First();

            CommandResult <Car> createResult = await _mediator.Send(new CreateEntityCommand <Car>(car));

            createResult.Result.Should().Be(CommandState.Success);
            createResult.Entity.Id.Should().BePositive();

            QueryResult <Car> searchResult = await _mediator.Send(new GenericQueryCommand <Car>(new BaseCarQuery()
            {
                ID = createResult.Entity.Id
            }));

            searchResult.Results.Should().HaveCount(1);
            searchResult.Results[0].Name.Should().Be(car.Name);
        }
Exemple #6
0
        public async Task GenericUpdateCommand_BasicTest()
        {
            var carService = Resolve <ICarService>();
            CommandResult <Car> newCarResult = await carService.CreateAsync(TestCarsCatalog.GetCars().First());

            newCarResult.Result.Should().Be(CommandState.Success);

            Car car = newCarResult.Entity;

            car.Name = $"car.Name{DateTime.Now.Ticks}";

            CommandResult <Car> updateResult = await _mediator.Send(new UpdateEntityCommand <Car>(car));

            updateResult.Result.Should().Be(CommandState.Success);

            QueryResult <Car> searchResult = await _mediator.Send(new GenericQueryCommand <Car>(new BaseCarQuery()
            {
                ID = car.Id
            }));

            searchResult.Results.Should().HaveCount(1);
            searchResult.Results[0].Name.Should().Be(car.Name);
        }