public void ShouldReferencedCorrectly() { var repository = new MemoryRepository.Repository(); string product1Id; string product2Id; string orderId; using (var transaction = repository.CreateTransaction <OrderTransaction>("Create products.")) { var product1 = transaction.CreateProduct("product1"); var product2 = transaction.CreateProduct("product2"); transaction.Commit(); product1Id = transaction.GetIdentity(product1); product2Id = transaction.GetIdentity(product2); } using (var transaction = repository.CreateTransaction <OrderTransaction>("Create order.")) { var customer = transaction.CreateCustomer("Customer name"); var order = transaction.CreateOrder(customer.GetReference()); order.AddLine(order.CreateLine(transaction.GetEntity <Product>(product1Id).GetReference())); order.AddLine(order.CreateLine(transaction.GetEntity <Product>(product2Id).GetReference())); transaction.Commit(); orderId = transaction.GetIdentity(order); } using (var transaction = repository.CreateTransaction <OrderTransaction>("Create order.")) { var order = transaction.GetEntity <Order>(orderId); var customer = order.Customer.Load(); var product = order.Lines.First().Product.Load(); Assert.Equal("product1", product.Name); Assert.Equal("Customer name", customer.Name); } }
public void EventMethodShouldReturnVoid() { var repository = new MemoryRepository.Repository(); var ex = Assert.Throws <InvalidOperationException>(() => repository.CreateTransaction <NonVoidEvent>("Started EventMethodShouldReturnVoid test.")); Assert.Equal("Event method \"SetDescription\" should return void.", ex.Message); }
public void ShouldSerializeDeserializeTranzaction() { var repository = new MemoryRepository.Repository(); string identity; using (var transaction = repository.CreateTransaction <TestTransaction>("Started test transaction.")) { var entity = transaction.CreateTestEntity("TestName"); entity.MakeOperation1(456); transaction.SetCreator("Oleg"); transaction.Commit(); identity = transaction.GetIdentity(transaction); } using (var transaction = repository.GetTransaction <TestTransaction>(identity)) { Assert.Equal("Started test transaction.", transaction.Description); Assert.Equal("Oleg", transaction.Creator); } }
public void ShouldGetCommitedEntity() { var repository = new MemoryRepository.Repository(); string identity; using (var transaction = repository.CreateTransaction <TestTransaction>("Started ShouldGetCommitEntity test.")) { var entity = transaction.CreateTestEntity("TestName"); entity.MakeOperation1(456); transaction.Commit(); identity = transaction.GetIdentity(entity); } using (var transaction = repository.CreateTransaction <TestTransaction>("Started ShouldGetCommitEntity test part 2.")) { var entity = transaction.GetEntity <TestEntity>(identity); Assert.Equal("TestName", entity.Name); Assert.Equal("AfterMakeOperation1", entity.State); Assert.Equal(456, entity.Testparametr); } }