private static void RegisterProductDependency(HttpConfiguration config) { var container = new UnityContainer(); var dbContext = new NoodleDbContext("NoodleDb"); container.RegisterType <IUnitRepository, UnitRepository>(new InjectionConstructor(dbContext)); container.RegisterType <ICategoryService, CategoryTreeService>(new InjectionConstructor(dbContext)); container.RegisterType <IProductRepository, ProductRepository>(new InjectionConstructor(dbContext)); container.RegisterType <IProductCategoryService, ProductCategoryService>(new InjectionConstructor(dbContext)); container.RegisterType <IProductPriceService, ProductPriceService>(new InjectionConstructor(dbContext)); container.RegisterType <IUomRepository, UomRepository>(new InjectionConstructor(dbContext)); container.RegisterType <ILocationRepository, LocationRepository>(new InjectionConstructor(dbContext)); container.RegisterType <ICurrencyRepository, CurrencyRepository>(new InjectionConstructor(dbContext)); container.RegisterType <IAddressRepository, AddressRepository>(new InjectionConstructor(dbContext)); container.RegisterType <IEmployeeRepository, EmployeeRepository>(new InjectionConstructor(dbContext)); container.RegisterType <IOrderRepository, OrderRepository>(new InjectionConstructor(dbContext)); container.RegisterType <IOrderLineRepository, OrderLineRepository>(new InjectionConstructor(dbContext)); container.RegisterType <IOrderLineDetailRepository, OrderLineDetailRepository>(new InjectionConstructor(dbContext)); container.RegisterType <IUserRepository, UserRepository>(new InjectionConstructor(dbContext)); container.RegisterType <IContactRepository, ContactRepository>(new InjectionConstructor(dbContext)); container.RegisterType <IContactDetailRepository, ContactDetailRepository>(new InjectionConstructor(dbContext)); container.RegisterType <IPersonRepository, PersonRepository>(new InjectionConstructor(dbContext)); container.RegisterType <ILinkRepository, LinkRepository>(new InjectionConstructor(dbContext)); container.RegisterType <IProductSpecificationRepository, ProductSpecificationRepository>(new InjectionConstructor(dbContext)); container.RegisterType <ILogger, Logger>(new InjectionFactory(x => LogManager.GetCurrentClassLogger())); config.DependencyResolver = new UnityResolver(container); }
public void RoleCRUDTest() { var context = new NoodleDbContext("NoodleDb"); IRoleRepository service = new RoleRepository(context); var ID_ = Guid.NewGuid(); var KEY_ = Guid.NewGuid().ToString(); var Name_ = Guid.NewGuid().ToString(); var record = new Role { Id = ID_, Key = KEY_, Name = Name_ }; service.Create(record); record.Name = Guid.NewGuid().ToString(); service.Update(record); var record2 = service.GetById(ID_); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.Key, record2.Key); service.Delete(record.Id); var record3 = service.GetById(ID_); Assert.IsNull(record3); }
public async Task LinkRepositoryCRUDTest() { var context = new NoodleDbContext("NoodleDb"); context.Init(); ILinkRepository repository = new LinkRepository(context); var id = Guid.NewGuid(); var record = new Link { Id = id, ReferenceId = Guid.Empty, Uri = "test" }; await repository.CreateAsync(record); record.Uri = "U_" + record.Uri; await repository.UpdateAsync(record); var record2 = await repository.GetByIdAsync(id); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.Uri, record2.Uri); await repository.DeleteAsync(record.Id); var record3 = await repository.GetByIdAsync(id); Assert.IsNull(record3); }
public void UserIdentityCRUDTest() { var context = new NoodleDbContext("NoodleDb"); IUserIdentityRepository service = new UserIdentityRepository(context); var ID_ = Guid.NewGuid(); var PROVIDER_ = "tst"; var KEY_ = Guid.NewGuid().ToString(); var record = new UserIdentity { Id = ID_, Provider = PROVIDER_, Key = KEY_ }; service.Create(record); record.Key = Guid.NewGuid().ToString(); service.Update(record); var record2 = service.GetById(ID_); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.Key, record2.Key); service.Delete(record.Id); var record3 = service.GetById(ID_); Assert.IsNull(record3); }
public void CategoryCRUDTest() { var context = new NoodleDbContext("NoodleDb"); ICategoryService service = new CategoryTreeService(context); var id = Guid.NewGuid(); var record = new Category { Id = id, Key = "Key_" + id.ToString(), Name = "Name_" + id.ToString() }; service.Create(record); record.Key = "U_" + record.Key; record.Name = "U_" + record.Name; service.Update(record); var record2 = service.GetById(id); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.Key, record2.Key); Assert.AreEqual(record.Name, record2.Name); service.Delete(record.Id); var record3 = service.GetById(id); Assert.IsNull(record3); }
public void AddressRepositoryCRUDTest() { var context = new NoodleDbContext("NoodleDb"); context.Init(); IAddressRepository repository = new AddressRepository(context); var id = Guid.NewGuid(); var record = new Address { Id = id, City = "_City", Country = "_Contry", Elevation = 0.1f, Latitude = 0.1f, Line1 = "_Line1" + id.ToString(), Line2 = "_Line2" + id.ToString(), Longitude = 0.1f, Postalcode = "_Postalcode", Type = "_Type" }; repository.Create(record); record.City = "U_" + record.City; record.Country = "U_" + record.Country; record.Line1 = "U_" + record.Line1; record.Line2 = "U_" + record.Line2; record.Postalcode = "U_" + record.Postalcode; record.Type = "U_" + record.Type; record.Elevation = 0.2f; record.Latitude = 0.2f; record.Longitude = 0.2f; repository.Update(record); var UpdatedRecord = repository.GetById(id); Assert.AreEqual(record.Id, UpdatedRecord.Id); Assert.AreEqual(record.City, UpdatedRecord.City); Assert.AreEqual(record.Country, UpdatedRecord.Country); Assert.AreEqual(record.Line1, UpdatedRecord.Line1); Assert.AreEqual(record.Line2, UpdatedRecord.Line2); Assert.AreEqual(record.Postalcode, UpdatedRecord.Postalcode); Assert.AreEqual(record.Type, UpdatedRecord.Type); Assert.AreEqual(record.Elevation, UpdatedRecord.Elevation); Assert.AreEqual(record.Latitude, UpdatedRecord.Latitude); Assert.AreEqual(record.Longitude, UpdatedRecord.Longitude); repository.Delete(record.Id); var deletedRecord = repository.GetById(id); Assert.IsNull(deletedRecord); }
public void OrderRepositoryCRUDTest() { var context = new NoodleDbContext("NoodleDb"); context.Init(); IOrderRepository repository = new OrderRepository(context); var id = Guid.NewGuid(); var record = new Order { Id = id, Amount = 10, BaseAmount = 10, CurrencyId = Guid.NewGuid(), CustomerId = Guid.NewGuid(), Date = new DateTime(2000, 1, 1), DestinationId = Guid.NewGuid(), DueDate = new DateTime(2001, 1, 1), LinesCount = 5, Number = "SO001", SourceId = Guid.NewGuid(), Type = "SO", StatusCode = "DRAFT" }; repository.Create(record); record.Amount = 15; record.Number = "SO002"; repository.Update(record); var record2 = repository.GetById(id); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.Amount, record2.Amount); Assert.AreEqual(record.BaseAmount, record2.BaseAmount); Assert.AreEqual(record.CurrencyId, record2.CurrencyId); Assert.AreEqual(record.CustomerId, record2.CustomerId); Assert.AreEqual(record.Date, record2.Date); Assert.AreEqual(record.DestinationId, record2.DestinationId); Assert.AreEqual(record.DueDate, record2.DueDate); Assert.AreEqual(record.LinesCount, record2.LinesCount); Assert.AreEqual(record.Number, record2.Number); Assert.AreEqual(record.SourceId, record2.SourceId); Assert.AreEqual(record.Type, record2.Type); Assert.AreEqual(record.StatusCode, record2.StatusCode); repository.Delete(record.Id); var record3 = repository.GetById(id); Assert.IsNull(record3); }
public void OrderLineRepositoryCRUDTest() { var context = new NoodleDbContext("NoodleDb"); context.Init(); IOrderLineRepository repository = new OrderLineRepository(context); var id = Guid.NewGuid(); var record = new OrderLine { Id = id, BasePrice = .1f, BaseQty = .1f, Price = .1f, Priority = 1, Qty = .1f, Amount = 10, BaseAmount = 10 }; repository.Create(record); record.BasePrice = .2f; record.BaseQty = .2f; record.Price = .2f; record.Priority = 2; record.Qty = .2f; record.Amount = 11; record.BaseAmount = 11; repository.Update(record); var updatedRecord = repository.GetById(id); Assert.AreEqual(record.Id, updatedRecord.Id); Assert.AreEqual(record.BasePrice, updatedRecord.BasePrice); Assert.AreEqual(record.BaseQty, updatedRecord.BaseQty); Assert.AreEqual(record.Price, updatedRecord.Price); Assert.AreEqual(record.Priority, updatedRecord.Priority); Assert.AreEqual(record.Qty, updatedRecord.Qty); Assert.AreEqual(record.Amount, updatedRecord.Amount); Assert.AreEqual(record.BaseAmount, updatedRecord.BaseAmount); repository.Delete(record.Id); var deletedRecord = repository.GetById(id); Assert.IsNull(deletedRecord); }
public void ContactDetailCRUDTest() { var context = new NoodleDbContext("NoodleDb"); IContactDetailRepository service = new ContactDetailRepository(context); var ID_ = Guid.NewGuid(); var CONTACT_GUID_ = Guid.NewGuid(); var PRIORITY_ = Int16.MaxValue; var TYPE_ = "ТИП"; var VALUE_ = "VAL"; var VERIFIED_ = false; var ALLOW_ = false; var record = new ContactDetail { Id = ID_, ContactGuid = CONTACT_GUID_, Priority = PRIORITY_, Type = TYPE_, Value = VALUE_, Verified = VERIFIED_, Allow = ALLOW_ }; service.Create(record); record.ContactGuid = Guid.NewGuid(); record.Type = "ТИП1"; record.Value = "VAL1"; record.Verified = true; record.Allow = true; service.Update(record); var record2 = service.GetById(ID_); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.ContactGuid, record2.ContactGuid); Assert.AreEqual(record.Type, record2.Type); Assert.AreEqual(record.Value, record2.Value); Assert.AreEqual(record.Verified, record2.Verified); Assert.AreEqual(record.Allow, record2.Allow); service.Delete(record.Id); var record3 = service.GetById(ID_); Assert.IsNull(record3); }
public async Task ProductSpecificationRepositoryCRUDTest() { var context = new NoodleDbContext("NoodleDb"); context.Init(); IProductSpecificationRepository repository = new ProductSpecificationRepository(context); var id = Guid.NewGuid(); var record = new ProductSpecification { Id = id, BaseQty = 10, Child = new Product { Id = Guid.Empty }, ChildUom = new Data.Business.Uom { Id = Guid.Empty }, Parent = new Product { Id = Guid.Empty } }; await repository.CreateAsync(record); record.BaseQty = 15; await repository.UpdateAsync(record); var record2 = await repository.GetByIdAsync(id); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.BaseQty, record2.BaseQty); await repository.DeleteAsync(record.Id); var record3 = await repository.GetByIdAsync(id); Assert.IsNull(record3); }
public void EmployeeRepositoryCRUDTest() { var context = new NoodleDbContext("NoodleDb"); context.Init(); IEmployeeRepository repository = new EmployeeRepository(context); var id = Guid.NewGuid(); var record = new Employee { Id = id, UnitId = Guid.NewGuid(), PersonId = Guid.NewGuid() }; repository.Create(record); record.UnitId = Guid.NewGuid(); record.PersonId = Guid.NewGuid(); repository.Update(record); var updatedRecord = repository.GetById(id); Assert.AreEqual(record.Id, updatedRecord.Id); Assert.AreEqual(record.PersonId, updatedRecord.PersonId); Assert.AreEqual(record.UnitId, updatedRecord.UnitId); var employeesByPersonId = repository.GetByPersonId(record.PersonId); var employeesByUnitId = repository.GetByUnitId(record.UnitId); Assert.IsNotNull(employeesByPersonId); Assert.IsNotNull(employeesByUnitId); repository.Delete(record.Id); var deletedRecord = repository.GetById(id); Assert.IsNull(deletedRecord); }
public void OrderLineDetailRepositoryCRUDTest() { var context = new NoodleDbContext("NoodleDb"); context.Init(); IOrderLineDetailRepository repository = new OrderLineDetailRepository(context); var id = Guid.NewGuid(); var record = new OrderLineDetail { Id = id, BaseQty = .1f, Priority = 1, Qty = .1f, Number = "SO001" }; repository.Create(record); record.BaseQty = .2f; record.Priority = 2; record.Qty = .2f; record.Number = "SO002"; repository.Update(record); var updatedRecord = repository.GetById(id); Assert.AreEqual(record.Id, updatedRecord.Id); Assert.AreEqual(record.BaseQty, updatedRecord.BaseQty); Assert.AreEqual(record.Priority, updatedRecord.Priority); Assert.AreEqual(record.Qty, updatedRecord.Qty); Assert.AreEqual(record.Number, updatedRecord.Number); repository.Delete(record.Id); var deletedRecord = repository.GetById(id); Assert.IsNull(deletedRecord); }
public void LocationRepositoryCRUDTest() { var context = new NoodleDbContext("NoodleDb"); context.Init(); ILocationRepository repository = new LocationRepository(context); var id = Guid.NewGuid(); var record = new Location { Id = id, UnitId = Guid.Empty, Type = "STORE", Key = "Key_" + id.ToString(), Name = "Name_" + id.ToString() }; repository.Create(record); record.Key = "U_" + record.Key; record.Name = "U_" + record.Name; record.Type = "HOME"; repository.Update(record); var updatedRecord = repository.GetById(id); Assert.AreEqual(record.Id, updatedRecord.Id); Assert.AreEqual(record.Key, updatedRecord.Key); Assert.AreEqual(record.Name, updatedRecord.Name); Assert.AreEqual(record.Type, updatedRecord.Type); repository.Delete(record.Id); var deletedRecord = repository.GetById(id); Assert.IsNull(deletedRecord); }
public void ProductPriceServiceCRUDTest() { var context = new NoodleDbContext("NoodleDb"); context.Init(); IProductPriceService service = new ProductPriceService(context); var id = Guid.NewGuid(); var productId = Guid.NewGuid(); var record = new ProductPrice { Id = id, ProductId = productId, Price = 10, CurrencyCode = "USD" }; service.Create(record); record.Price = 20; service.Update(record); var record2 = service.GetById(id); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.ProductId, record2.ProductId); Assert.AreEqual(record.Price, record2.Price); Assert.AreEqual(record.CurrencyCode, record2.CurrencyCode); service.Delete(record.Id); var record3 = service.GetById(id); Assert.IsNull(record3); }
public void PersonCRUDTest() { var context = new NoodleDbContext("NoodleDb"); IPersonRepository service = new PersonRepository(context); var ID_ = Guid.NewGuid(); var FIRSTNAME_ = Guid.NewGuid().ToString(); var LASTNAME_ = Guid.NewGuid().ToString(); var record = new Person { Id = ID_, Firstname = FIRSTNAME_, Lastname = LASTNAME_ }; service.Create(record); record.Lastname = Guid.NewGuid().ToString(); record.Birthdate = Convert.ToDateTime("2016-04-01 15:41:00"); service.Update(record); var record2 = service.GetById(ID_); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.Lastname, record2.Lastname); Assert.AreEqual(record.Firstname, record2.Firstname); Assert.AreEqual(record.Birthdate, record2.Birthdate); service.Delete(record.Id); var record3 = service.GetById(ID_); Assert.IsNull(record3); }
public void UserCRUDTest() { var context = new NoodleDbContext("NoodleDb"); IUserRepository service = new UserRepository(context); var ID_ = Guid.NewGuid(); var KEY_ = Guid.NewGuid().ToString(); var record = new User { Id = ID_, Key = KEY_, LastLogin = Convert.ToDateTime("2016-04-01 15:41:00") }; service.Create(record); record.Key = Guid.NewGuid().ToString(); record.LastLogin = Convert.ToDateTime("2016-04-02 15:41:00"); record.LoginAttemptCount = 1; service.Update(record); var record2 = service.GetById(ID_); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.Key, record2.Key); Assert.AreEqual(record.LastLogin, record2.LastLogin); Assert.AreEqual(record.LoginAttemptCount, record2.LoginAttemptCount); service.Delete(record.Id); var record3 = service.GetById(ID_); Assert.IsNull(record3); }
public void UserRoleCRUDTest() { var context = new NoodleDbContext("NoodleDb"); IUserRoleRepository service = new UserRoleRepository(context); var ID_ = Guid.NewGuid(); var USER_GUID_ = Guid.NewGuid(); var ROLE_GUID_ = Guid.NewGuid(); var record = new UserRole { Id = ID_, UserGuid = USER_GUID_, RoleGuid = ROLE_GUID_ }; service.Create(record); record.UserGuid = Guid.NewGuid(); record.RoleGuid = Guid.NewGuid(); service.Update(record); var record2 = service.GetById(ID_); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.RoleGuid, record2.RoleGuid); Assert.AreEqual(record.UserGuid, record2.UserGuid); service.Delete(record.Id); var record3 = service.GetById(ID_); Assert.IsNull(record3); }
public void CurrencyRepositoryCRUDTest() { var context = new NoodleDbContext("NoodleDb"); context.Init(); ICurrencyRepository repository = new CurrencyRepository(context); var id = Guid.NewGuid(); var record = new Currency { Id = id, Key = "Key_" + id.ToString(), Name = "Name_" + id.ToString() }; repository.Create(record); record.Key = "U_" + record.Key; record.Name = "U_" + record.Name; repository.Update(record); var record2 = repository.GetById(id); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.Key, record2.Key); Assert.AreEqual(record.Name, record2.Name); repository.Delete(record.Id); var record3 = repository.GetById(id); Assert.IsNull(record3); }
public void ProdutServiceCRUDTest() { var context = new NoodleDbContext("NoodleDb"); IProductRepository service = new ProductRepository(context); var id = Guid.NewGuid(); var record = new Product { Id = id, Key = "Key_" + id.ToString(), Name = "Name_" + id.ToString(), Type = "REGULAR" }; service.Create(record); record.Key = "U_" + record.Key; record.Name = "U_" + record.Name; service.Update(record); var record2 = service.GetById(id); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.Key, record2.Key); Assert.AreEqual(record.Name, record2.Name); Assert.AreEqual(record.Type, record2.Type); service.Delete(record.Id); var record3 = service.GetById(id); Assert.IsNull(record3); }
public void ProductCategoryServiceCRUDTest() { var context = new NoodleDbContext("NoodleDb"); IProductCategoryService service = new ProductCategoryService(context); var id = Guid.NewGuid(); var productId = Guid.NewGuid(); var categoryId = Guid.NewGuid(); var record = new ProductCategory { Id = id, ProductId = productId, CategoryId = categoryId }; service.Create(record); record.CategoryId = Guid.NewGuid(); record.ProductId = Guid.NewGuid(); service.Update(record); var record2 = service.GetById(id); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.CategoryId, record2.CategoryId); Assert.AreEqual(record.ProductId, record2.ProductId); service.Delete(record.Id); var record3 = service.GetById(id); Assert.IsNull(record3); }
public void ContactCRUDTest() { var context = new NoodleDbContext("NoodleDb"); IContactRepository service = new ContactRepository(context); var ID_ = Guid.NewGuid(); var RECORD_GUID_ = Guid.NewGuid(); var TYPE_ = "ТИП"; var record = new Contact { Id = ID_, RecordGuid = RECORD_GUID_, Type = TYPE_ }; service.Create(record); record.RecordGuid = Guid.NewGuid(); record.Type = "ТИП1"; service.Update(record); var record2 = service.GetById(ID_); Assert.AreEqual(record.Id, record2.Id); Assert.AreEqual(record.RecordGuid, record2.RecordGuid); Assert.AreEqual(record.Type, record2.Type); service.Delete(record.Id); var record3 = service.GetById(ID_); Assert.IsNull(record3); }
public void UomRepositoryCRUDTest() { var context = new NoodleDbContext("NoodleDb"); context.Init(); IUomRepository repository = new UomRepository(context); var id = Guid.NewGuid(); var record = new Uom { Id = id, Key = "Key_" + id.ToString(), Name = "Name_" + id.ToString() }; repository.Create(record); record.Key = "U_" + record.Key; record.Name = "U_" + record.Name; repository.Update(record); var UpdatedRecord = repository.GetById(id); Assert.AreEqual(record.Id, UpdatedRecord.Id); Assert.AreEqual(record.Key, UpdatedRecord.Key); Assert.AreEqual(record.Name, UpdatedRecord.Name); repository.Delete(record.Id); var deletedRecord = repository.GetById(id); Assert.IsNull(deletedRecord); }
public void CreateDbTest() { var context = new NoodleDbContext("NoodleDb"); context.Init(); }