示例#1
0
        public static async Task Cleanup()
        {
            var reader   = new EntityReader <EventResource>();
            var toDelete = new EventResource();

            foreach (Guid item in RecycleBin)
            {
                toDelete = reader.GetAll().Where(x => x.Key == item).FirstOrDefaultSafe();
                using (var db = new EntityWriter <EventResource>(toDelete, new EventResourceSPConfig()))
                {
                    await db.DeleteAsync();
                }
            }
        }
示例#2
0
        public async Task Event_EventResource_Read()
        {
            var reader     = new EntityReader <EventResource>();
            var testEntity = new EventResource();
            var lastKey    = Defaults.Guid;

            await Event_EventResource_Create();

            lastKey = EventResourceTests.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);
        }
示例#3
0
        public void Event_EventResource_Serialize()
        {
            var searchChar     = "i";
            var originalObject = new EventResource()
            {
                ResourceName = searchChar, ResourceDescription = searchChar
            };
            var resultObject = new EventResource();
            var resultString = Defaults.String;
            var serializer   = new JsonSerializer <EventResource>();

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

            await Event_EventResource_Create();

            lastKey = EventResourceTests.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 <EventResource>(testEntity, new EventResourceSPConfig()))
            {
                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);
        }