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(); } } }
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); }
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); }
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); }