public void LookupManager_Update_UpdateALookupEntity_UpdatedSuccessfully()
        {
            ILookupManager<BusinessTypeCC2> manager = new BusinessTypeCC2Manager();

            var t = manager.Create(new BusinessTypeCC2()
            {
                Name = "Some Business",
                Description = "Some Business Description",
                Code = "SOMEBIZ1818",
                Active = true
            });

            Assert.IsTrue(t);

            var all = manager.Get(false);

            var result =
                manager.Update(new BusinessTypeCC2()
                    {
                        Id = all[0].Id,
                        Name = "Some Other Business",
                        Description = "Some Business Description 24",
                        Code = "SOMEBIZ4546",
                        Active = false
                    });

            Assert.IsTrue(result);
        }
        public void LookupManager_Create_CreateALookupEntityWithNullEntity_ThrowsException()
        {
            ILookupManager<BusinessTypeCC2> manager = new BusinessTypeCC2Manager();

            var id = manager.Create(null);

            Assert.Fail("Should have thrown exception!");
        }
        public void LookupManager_Create_CreateALookupEntity_CreatedSuccessfully()
        {
            ILookupManager<BusinessTypeCC2> manager = new BusinessTypeCC2Manager();

            var id =
                manager.Create(new BusinessTypeCC2()
                    {
                        Name = "Some Business",
                        Description = "Some Business Description",
                        Code = "SOMEBIZ",
                        Active = true
                    });

            Assert.IsTrue(id);
        }
        public void LookupManager_Create_CreateALookupEntityUsingInvalidConnectionStringName_ThrowsException()
        {
            ILookupManager<BusinessTypeCC2> manager = new BusinessTypeCC2Manager();

            var id =
                manager.Create(new BusinessTypeCC2()
                {
                    Name = "Some Business",
                    Description = "Some Business Description",
                    Code = "SOMEBIZ",
                    Active = true
                }, "SomeInvalidName");

            Assert.Fail("Should have thrown exception!");
        }
        public void LookupManager_Get_SelectAllLookups_RetrievedSuccessfully()
        {
            ILookupManager<BusinessTypeCC2> manager = new BusinessTypeCC2Manager();

            var result = manager.Get(false);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count > 0);

            foreach (var r in result)
            {
                Assert.IsTrue(r.Id > 0);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(r.Name));
                Assert.IsTrue(!string.IsNullOrWhiteSpace(r.Description));
                Assert.IsTrue(!string.IsNullOrWhiteSpace(r.Code));
            }
        }
        public void LookupManager_Delete_DeleteALookupEntityByCodeUsingAltConnectionName_DeletedSuccessfully()
        {
            ILookupManager<BusinessTypeCC2> manager = new BusinessTypeCC2Manager();

            var t = manager.Create(new BusinessTypeCC2()
            {
                Name = "Some Business",
                Description = "Some Business Description",
                Code = "SOMEBIZ9898",
                Active = true
            });

            Assert.IsTrue(t);
            var all = manager.Get(false);

            var result = manager.Delete("SOMEBIZ9898", "Other");

            Assert.IsTrue(result);
        }
        public void LookupManager_Delete_DeleteALookupEntityByCodes_DeletedSuccessfully()
        {
            ILookupManager<BusinessTypeCC2> manager = new BusinessTypeCC2Manager();

            var t = manager.Create(new BusinessTypeCC2()
            {
                Name = "Some Business",
                Description = "Some Business Description",
                Code = "SOMEBIZ2424",
                Active = true
            });

            Assert.IsTrue(t);

            var all = manager.Get(false);

            var result = manager.Delete(new List<string>() { "SOMEBIZ2424" });

            Assert.IsTrue(result);
        }
        public void LookupManager_Delete_DeleteALookupEntityById_DeletedSuccessfully()
        {
            ILookupManager <BusinessTypeCC2> manager = new BusinessTypeCC2Manager();

            var t = manager.Create(new BusinessTypeCC2()
            {
                Name        = "Some Business",
                Description = "Some Business Description",
                Code        = "SOMEBIZ1919",
                Active      = true
            });

            Assert.IsTrue(t);

            var all = manager.Get(false);

            var result = manager.Delete(all[0].Id);

            Assert.IsTrue(result);
        }
        public void LookupManager_Delete_DeleteALookupEntityByCodesUsingAltConnectionName_DeletedSuccessfully()
        {
            ILookupManager <BusinessTypeCC2> manager = new BusinessTypeCC2Manager();

            var t = manager.Create(new BusinessTypeCC2()
            {
                Name        = "Some Business",
                Description = "Some Business Description",
                Code        = "SOMEBIZ757",
                Active      = true
            });

            Assert.IsTrue(t);

            var all = manager.Get(false);

            var result = manager.Delete(new List <string>()
            {
                "SOMEBIZ757"
            }, "Other");

            Assert.IsTrue(result);
        }
        public void LookupManager_Delete_DeleteALookupEntityByInvalidId_ReturnsFalse()
        {
            ILookupManager<BusinessTypeCC2> manager = new BusinessTypeCC2Manager();

            var result = manager.Delete(-495);

            Assert.IsFalse(result);
        }
        public void LookupManager_Delete_DeleteALookupEntityByIds_DeletedSuccessfully()
        {
            ILookupManager<BusinessTypeCC2> manager = new BusinessTypeCC2Manager();

            var t = manager.Create(new BusinessTypeCC2()
                {
                    Name = "Some Business",
                    Description = "Some Business Description",
                    Code = "SOMEBIZ1717",
                    Active = true
                });

            Assert.IsTrue(t);

            var all = manager.Get(false);

            var result = manager.Delete(all.Select(d => d.Id).Take(1).ToList());

            Assert.IsTrue(result);
        }
        public void LookupManager_Get_SelectALookupEntityByCodeUsingAltConnectionName_RetrievedSuccessfully()
        {
            ILookupManager<BusinessTypeCC2> manager = new BusinessTypeCC2Manager();

            var all = manager.Get(true);
            var result = manager.Get(all[0].Code, "Other");

            Assert.IsTrue(result.Id > 0);
            Assert.IsTrue(!string.IsNullOrWhiteSpace(result.Name));
            Assert.IsTrue(!string.IsNullOrWhiteSpace(result.Description));
            Assert.IsTrue(!string.IsNullOrWhiteSpace(result.Code));
            Assert.IsTrue(result.Active);
        }
        public void LookupManager_Get_SelectLookupEntitiesByIds_RetrievedSuccessfully()
        {
            ILookupManager<BusinessTypeCC2> manager = new BusinessTypeCC2Manager();

            var all = manager.Get(true);
            var result = manager.Get(all.Select(o => o.Id).ToList());

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count > 0);

            foreach (var r in result)
            {
                Assert.IsTrue(r.Id > 0);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(r.Name));
                Assert.IsTrue(!string.IsNullOrWhiteSpace(r.Description));
                Assert.IsTrue(!string.IsNullOrWhiteSpace(r.Code));
                Assert.IsTrue(r.Active);
            }
        }