Ejemplo n.º 1
0
        public async Task TestAddAsync()
        {
            Guid id    = Guid.NewGuid();
            var  order = new Order(id)
            {
                Name = "Name", Code = "Code"
            };
            await _orderRepository.AddAsync(order);

            await _unitOfWork.CommitAsync();

            var result = await _orderRepository.SingleAsync(t => t.Id == id);

            Assert.Equal(id, result.Id);
        }
Ejemplo n.º 2
0
        public async Task TestToStringAsync()
        {
            string id       = Id.ObjectId();
            string name     = Id.Guid().Substring(0, 10);
            var    customer = new Customer(id)
            {
                Name = name
            };
            await _customerRepository.AddAsync(customer);

            await _unitOfWork.CommitAsync();

            var result = await _query
                         .Select <Customer>(t => t.Name)
                         .From <Customer>("c")
                         .Where <Customer>(t => t.Id == id)
                         .ToStringAsync();

            _output.WriteLine(_query.GetDebugSql());
            Assert.Equal(name, result);
        }
Ejemplo n.º 3
0
        public async Task TestAddAsync()
        {
            int id      = _random.Next(999999999);
            var product = new Product(id)
            {
                Name = "Name", Code = "Code"
            };

            product.ProductType = new ProductType("Type", new List <ProductProperty>()
            {
                new ProductProperty("A", "1"), new ProductProperty("B", "2")
            });
            await _productRepository.AddAsync(product);

            await _unitOfWork.CommitAsync();

            Product result = _productRepository.GetById(id);

            Assert.Equal(id, result.Id);
            Assert.Equal("Type", result.ProductType.Name);
            Assert.Equal("2", result.ProductType.Properties.ToList()[1].Value);
        }
Ejemplo n.º 4
0
        public async Task TestToAsync()
        {
            string id       = Id.ObjectId();
            string name     = Id.Guid().Substring(0, 10);
            var    customer = new Customer(id)
            {
                Name = name
            };
            await _customerRepository.AddAsync(customer);

            await _unitOfWork.CommitAsync();

            var result = await _query.Select <Customer>(t => new object[] { t.Name })
                         .From <Customer>("Customers")
                         .Where("CustomerId", id)
                         .ToAsync <Customer>();

            Assert.Equal(name, result.Name);
        }