Example #1
0
        public async Task Entity_EntityTimeRecurring_Create()
        {
            var testEntity   = new EntityTimeRecurring();
            var resultEntity = new EntityTimeRecurring();
            var reader       = new EntityReader <EntityTimeRecurring>();
            var testClass    = new PersonInfoTests();

            // Create a base record
            await testClass.Person_PersonInfo_Create();

            // Create should update original object, and pass back a fresh-from-db object
            testEntity.Fill(testEntities[Arithmetic.Random(1, testEntities.Count)]);
            testEntity.EntityKey = PersonInfoTests.RecycleBin.LastOrDefault();
            using (var writer = new EntityWriter <EntityTimeRecurring>(testEntity, new EntityTimeRecurringSPConfig()))
            {
                resultEntity = await writer.SaveAsync();
            }
            Assert.IsTrue(!resultEntity.FailedRules.Any());
            Assert.IsTrue(testEntity.Id != Defaults.Integer);
            Assert.IsTrue(testEntity.Key != Defaults.Guid);
            Assert.IsTrue(resultEntity.Id != Defaults.Integer);
            Assert.IsTrue(resultEntity.Key != Defaults.Guid);

            // Object in db should match in-memory objects
            testEntity = reader.Read(x => x.Id == resultEntity.Id).FirstOrDefaultSafe();
            Assert.IsTrue(!testEntity.IsNew);
            Assert.IsTrue(testEntity.Id != Defaults.Integer);
            Assert.IsTrue(testEntity.Key != Defaults.Guid);
            Assert.IsTrue(testEntity.Id == resultEntity.Id);
            Assert.IsTrue(testEntity.Key == resultEntity.Key);

            EntityTimeRecurringTests.RecycleBin.Add(testEntity.Key);
        }
Example #2
0
        public async Task Entity_EntityTimeRecurring_Delete()
        {
            var reader       = new EntityReader <EntityTimeRecurring>();
            var testEntity   = new EntityTimeRecurring();
            var resultEntity = new EntityTimeRecurring();
            var lastKey      = Defaults.Guid;
            var originalId   = Defaults.Integer;
            var originalKey  = Defaults.Guid;

            await Entity_EntityTimeRecurring_Create();

            lastKey = EntityTimeRecurringTests.RecycleBin.LastOrDefault();

            testEntity  = reader.Read(x => x.Key == lastKey).FirstOrDefaultSafe();
            originalId  = testEntity.Id;
            originalKey = testEntity.Key;
            Assert.IsTrue(testEntity.Id != Defaults.Integer);
            Assert.IsTrue(testEntity.Key != Defaults.Guid);
            Assert.IsTrue(testEntity.CreatedDate.Date == DateTime.UtcNow.Date);

            using (var writer = new EntityWriter <EntityTimeRecurring>(testEntity, new EntityTimeRecurringSPConfig()))
            {
                resultEntity = await writer.DeleteAsync();
            }
            Assert.IsTrue(resultEntity.IsNew);

            testEntity = reader.Read(x => x.Id == originalId).FirstOrDefaultSafe();
            Assert.IsTrue(testEntity.Id != originalId);
            Assert.IsTrue(testEntity.Key != originalKey);
            Assert.IsTrue(testEntity.IsNew);
            Assert.IsTrue(testEntity.Key == Defaults.Guid);

            // Remove from RecycleBin (its already marked deleted)
            RecycleBin.Remove(lastKey);
        }
Example #3
0
        public static async Task Cleanup()
        {
            var reader   = new EntityReader <EntityTimeRecurring>();
            var toDelete = new EntityTimeRecurring();

            foreach (Guid item in RecycleBin)
            {
                toDelete = reader.GetAll().Where(x => x.Key == item).FirstOrDefaultSafe();
                using (var db = new EntityWriter <EntityTimeRecurring>(toDelete, new EntityTimeRecurringSPConfig()))
                {
                    await db.DeleteAsync();
                }
            }
        }
Example #4
0
        public async Task Entity_EntityTimeRecurring_Read()
        {
            var reader     = new EntityReader <EntityTimeRecurring>();
            var testEntity = new EntityTimeRecurring();
            var lastKey    = Defaults.Guid;

            await Entity_EntityTimeRecurring_Create();

            lastKey = EntityTimeRecurringTests.RecycleBin.LastOrDefault();

            testEntity = reader.Read(x => x.Key == lastKey).FirstOrDefaultSafe();
            Assert.IsTrue(!testEntity.IsNew);
            Assert.IsTrue(testEntity.Id != Defaults.Integer);
            Assert.IsTrue(testEntity.Key != Defaults.Guid);
            Assert.IsTrue(testEntity.CreatedDate.Date == DateTime.UtcNow.Date);
        }
Example #5
0
        public async Task Entity_EntityTimeRecurring_Update()
        {
            var reader       = new EntityReader <EntityTimeRecurring>();
            var resultEntity = new EntityTimeRecurring();
            var testEntity   = new EntityTimeRecurring();
            var uniqueValue  = Guid.NewGuid().ToString().Replace("-", "");
            var lastKey      = Defaults.Guid;
            var originalId   = Defaults.Integer;
            var originalKey  = Defaults.Guid;

            await Entity_EntityTimeRecurring_Create();

            lastKey = EntityTimeRecurringTests.RecycleBin.LastOrDefault();

            testEntity  = reader.Read(x => x.Key == lastKey).FirstOrDefaultSafe();
            originalId  = testEntity.Id;
            originalKey = testEntity.Key;
            Assert.IsTrue(!testEntity.IsNew);
            Assert.IsTrue(testEntity.Id != Defaults.Integer);
            Assert.IsTrue(testEntity.Key != Defaults.Guid);

            using (var writer = new EntityWriter <EntityTimeRecurring>(testEntity, new EntityTimeRecurringSPConfig()))
            {
                resultEntity = await writer.SaveAsync();
            }
            Assert.IsTrue(!resultEntity.IsNew);
            Assert.IsTrue(resultEntity.Id != Defaults.Integer);
            Assert.IsTrue(resultEntity.Key != Defaults.Guid);
            Assert.IsTrue(testEntity.Id == resultEntity.Id && resultEntity.Id == originalId);
            Assert.IsTrue(testEntity.Key == resultEntity.Key && resultEntity.Key == originalKey);

            testEntity = reader.Read(x => x.Id == originalId).FirstOrDefaultSafe();
            Assert.IsTrue(!testEntity.IsNew);
            Assert.IsTrue(testEntity.Id == resultEntity.Id && resultEntity.Id == originalId);
            Assert.IsTrue(testEntity.Key == resultEntity.Key && resultEntity.Key == originalKey);
            Assert.IsTrue(testEntity.Id != Defaults.Integer);
            Assert.IsTrue(testEntity.Key != Defaults.Guid);
        }