public async Task Resource_ResourceTimeRecurring_Create()
        {
            var testEntity   = new ResourceTimeRecurring();
            var resultEntity = new ResourceTimeRecurring();
            var reader       = new EntityReader <ResourceTimeRecurring>();

            // Create should update original object, and pass back a fresh-from-db object
            testEntity.Fill(testEntities[Arithmetic.Random(1, testEntities.Count)]);
            using (var writer = new EntityWriter <ResourceTimeRecurring>(testEntity, new ResourceTimeRecurringSPConfig()))
            {
                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);

            ResourceTimeRecurringTests.RecycleBin.Add(testEntity.Key);
        }
        public async Task Resource_ResourceTimeRecurring_Delete()
        {
            var reader       = new EntityReader <ResourceTimeRecurring>();
            var testEntity   = new ResourceTimeRecurring();
            var resultEntity = new ResourceTimeRecurring();
            var lastKey      = Defaults.Guid;
            var originalId   = Defaults.Integer;
            var originalKey  = Defaults.Guid;

            await Resource_ResourceTimeRecurring_Create();

            lastKey = ResourceTimeRecurringTests.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 <ResourceTimeRecurring>(testEntity, new ResourceTimeRecurringSPConfig()))
            {
                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);
        }
        public static async Task Cleanup()
        {
            var reader   = new EntityReader <ResourceTimeRecurring>();
            var toDelete = new ResourceTimeRecurring();

            foreach (Guid item in RecycleBin)
            {
                toDelete = reader.GetAll().Where(x => x.Key == item).FirstOrDefaultSafe();
                using (var db = new EntityWriter <ResourceTimeRecurring>(toDelete, new ResourceTimeRecurringSPConfig()))
                {
                    await db.DeleteAsync();
                }
            }
        }
        public async Task Resource_ResourceTimeRecurring_Read()
        {
            var reader     = new EntityReader <ResourceTimeRecurring>();
            var testEntity = new ResourceTimeRecurring();
            var lastKey    = Defaults.Guid;

            await Resource_ResourceTimeRecurring_Create();

            lastKey = ResourceTimeRecurringTests.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);
        }
        public void Resource_ResourceTimeRecurring_Serialize()
        {
            var searchChar     = "i";
            var originalObject = new ResourceTimeRecurring()
            {
                ResourceName = searchChar, ResourceDescription = searchChar
            };
            var resultObject = new ResourceTimeRecurring();
            var resultString = Defaults.String;
            var serializer   = new JsonSerializer <ResourceTimeRecurring>();

            resultString = serializer.Serialize(originalObject);
            Assert.IsTrue(resultString != Defaults.String);
            resultObject = serializer.Deserialize(resultString);
            Assert.IsTrue(resultObject.ResourceName == searchChar);
            Assert.IsTrue(resultObject.ResourceDescription == searchChar);
        }
        public async Task Resource_ResourceTimeRecurring_Update()
        {
            var reader       = new EntityReader <ResourceTimeRecurring>();
            var resultEntity = new ResourceTimeRecurring();
            var testEntity   = new ResourceTimeRecurring();
            var uniqueValue  = Guid.NewGuid().ToString().Replace("-", "");
            var lastKey      = Defaults.Guid;
            var originalId   = Defaults.Integer;
            var originalKey  = Defaults.Guid;

            await Resource_ResourceTimeRecurring_Create();

            lastKey = ResourceTimeRecurringTests.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);

            testEntity.ResourceName = uniqueValue;
            using (var writer = new EntityWriter <ResourceTimeRecurring>(testEntity, new ResourceTimeRecurringSPConfig()))
            {
                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);
        }