public async Task Venture_VentureLocation_Delete() { var reader = new EntityReader <VentureLocation>(); var testEntity = new VentureLocation(); var resultEntity = new VentureLocation(); var lastKey = Defaults.Guid; var originalId = Defaults.Integer; var originalKey = Defaults.Guid; await Venture_VentureLocation_Create(); lastKey = VentureLocationTests.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 <VentureLocation>(testEntity, new VentureLocationSPConfig())) { 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 async Task Entity_CustomerInfo_Delete() { var testEntity = new CustomerInfo(); var resultEntity = new CustomerInfo(); var lastKey = Defaults.Guid; var originalId = Defaults.Integer; var originalKey = Defaults.Guid; var reader = new EntityReader <CustomerInfo>(); await Entity_CustomerInfo_Create(); lastKey = CustomerEntityTests.RecycleBin.Last(); 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 StoredProcedureWriter <CustomerInfo>(testEntity, new CustomerSPConfig(testEntity))) { 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); }
public async Task Event_EventResource_Create() { var testEntity = new EventResource(); var resultEntity = new EventResource(); var reader = new EntityReader <EventResource>(); var testClass = new EventInfoTests(); var personTest = new PersonInfoTests(); // Create a base record await testClass.Event_EventInfo_Create(); // Create should update original object, and pass back a fresh-from-db object testEntity.Fill(testEntities[Arithmetic.Random(1, testEntities.Count)]); testEntity.EventKey = EventInfoTests.RecycleBin.LastOrDefault(); testEntity.EventCreatorKey = PersonInfoTests.RecycleBin.LastOrDefault(); using (var writer = new EntityWriter <EventResource>(testEntity, new EventResourceSPConfig())) { 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); EventResourceTests.RecycleBin.Add(testEntity.Key); }
public async Task Entity_CustomerInfo_Create() { var testEntity = new CustomerInfo(); var resultEntity = new CustomerInfo(); var reader = new EntityReader <CustomerInfo>(); // Create should update original object, and pass back a fresh-from-db object testEntity.Fill(testEntities[Arithmetic.Random(1, 5)]); using (var writer = new StoredProcedureWriter <CustomerInfo>(testEntity, new CustomerSPConfig(testEntity))) { resultEntity = await writer.SaveAsync(); } 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); CustomerEntityTests.RecycleBin.Add(testEntity.Key); }
public async Task Schedule_ScheduleInfo_Create() { var testEntity = new ScheduleInfo(); var resultEntity = new ScheduleInfo(); var reader = new EntityReader <ScheduleInfo>(); // 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 <ScheduleInfo>(testEntity, new ScheduleInfoSPConfig())) { resultEntity = await writer.SaveAsync(); } Assert.IsTrue(testEntity.Id != Defaults.Integer); Assert.IsTrue(testEntity.Key != Defaults.Guid); Assert.IsTrue(resultEntity.Id != Defaults.Integer); Assert.IsTrue(resultEntity.Key != Defaults.Guid); Assert.IsTrue(!resultEntity.FailedRules.Any()); // 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); Assert.IsTrue(!testEntity.FailedRules.Any()); ScheduleInfoTests.RecycleBin.Add(testEntity.Key); }
public async Task Venture_VentureLocation_Create() { var testEntity = new VentureLocation(); var resultEntity = new VentureLocation(); var reader = new EntityReader <VentureLocation>(); var VentureTest = new VentureInfoTests(); var personTest = new PersonInfoTests(); // Create Venture await VentureTest.Venture_VentureInfo_Create(); // Create should update original object, and pass back a fresh-from-db object testEntity.Fill(testEntities[Arithmetic.Random(1, testEntities.Count)]); testEntity.VentureKey = VentureInfoTests.RecycleBin.LastOrDefault(); using (var writer = new EntityWriter <VentureLocation>(testEntity, new VentureLocationSPConfig())) { 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); VentureLocationTests.RecycleBin.Add(testEntity.Key); }
public async Task Schedule_ScheduleInfo_Update() { var reader = new EntityReader <ScheduleInfo>(); var resultEntity = new ScheduleInfo(); var testEntity = new ScheduleInfo(); var uniqueValue = Guid.NewGuid().ToString().Replace("-", ""); var lastKey = Defaults.Guid; var originalId = Defaults.Integer; var originalKey = Defaults.Guid; await Schedule_ScheduleInfo_Create(); lastKey = ScheduleInfoTests.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); Assert.IsTrue(!testEntity.FailedRules.Any()); testEntity.Name = uniqueValue; using (var writer = new EntityWriter <ScheduleInfo>(testEntity, new ScheduleInfoSPConfig())) { 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); Assert.IsTrue(!testEntity.FailedRules.Any()); 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); Assert.IsTrue(!testEntity.FailedRules.Any()); }
public async Task Schedule_SlotTimeRange_Update() { var reader = new EntityReader <SlotTimeRange>(); var resultEntity = new SlotTimeRange(); var testEntity = new SlotTimeRange(); var lastKey = Defaults.Guid; var originalId = Defaults.Integer; var originalKey = Defaults.Guid; await Schedule_SlotTimeRange_Create(); lastKey = SlotTimeRangeTests.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); Assert.IsTrue(!testEntity.FailedRules.Any()); using (var writer = new EntityWriter <SlotTimeRange>(testEntity, new SlotTimeRangeSPConfig())) { 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); Assert.IsTrue(!testEntity.FailedRules.Any()); 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); Assert.IsTrue(!testEntity.FailedRules.Any()); }
public async Task Event_EventDetail_Update() { var reader = new EntityReader <EventDetail>(); var resultEntity = new EventDetail(); var testEntity = new EventDetail(); var uniqueValue = Guid.NewGuid().ToString().Replace("-", ""); var lastKey = Defaults.Guid; var originalId = Defaults.Integer; var originalKey = Defaults.Guid; await Event_EventDetail_Create(); lastKey = EventDetailTests.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.Description = uniqueValue; using (var writer = new EntityWriter <EventDetail>(testEntity, new EventDetailSPConfig())) { 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); }
public async Task Venture_VentureLocation_Update() { var reader = new EntityReader <VentureLocation>(); var resultEntity = new VentureLocation(); var testEntity = new VentureLocation(); var uniqueValue = Guid.NewGuid().ToString().Replace("-", ""); var lastKey = Defaults.Guid; var originalId = Defaults.Integer; var originalKey = Defaults.Guid; await Venture_VentureLocation_Create(); lastKey = VentureLocationTests.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.LocationName = uniqueValue; using (var writer = new EntityWriter <VentureLocation>(testEntity, new VentureLocationSPConfig())) { 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); }
public async Task Entity_CustomerInfo_Update() { var resultEntity = new CustomerInfo(); var testEntity = new CustomerInfo(); var uniqueValue = Guid.NewGuid().ToString().Replace("-", ""); var lastKey = Defaults.Guid; var originalId = Defaults.Integer; var originalKey = Defaults.Guid; var reader = new EntityReader <CustomerInfo>(); await Entity_CustomerInfo_Create(); lastKey = CustomerEntityTests.RecycleBin.Last(); 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.FirstName = uniqueValue; using (var writer = new StoredProcedureWriter <CustomerInfo>(testEntity, new CustomerSPConfig(testEntity))) { 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); }
public async Task Schedule_ScheduleSlot_Delete() { var reader = new EntityReader <ScheduleSlot>(); var testEntity = new ScheduleSlot(); var resultEntity = new ScheduleSlot(); var lastKey = Defaults.Guid; var originalId = Defaults.Integer; var originalKey = Defaults.Guid; await Schedule_ScheduleSlot_Create(); lastKey = ScheduleSlotTests.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); Assert.IsTrue(!testEntity.FailedRules.Any()); using (var writer = new EntityWriter <ScheduleSlot>(testEntity, new ScheduleSlotSPConfig())) { resultEntity = await writer.DeleteAsync(); } Assert.IsTrue(resultEntity.IsNew); Assert.IsTrue(!testEntity.FailedRules.Any()); 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); Assert.IsTrue(!testEntity.FailedRules.Any()); // Remove from RecycleBin (its already marked deleted) RecycleBin.Remove(lastKey); }
public void CountTest() { var reader = Dummy.CreateDataReader(Dummy.Foos.ToArray()); var mapping = Dummy.EntityMapping; var test = new EntityReader<Foo>(reader, mapping); int count = 0; while (test.Read()) { count++; } Assert.Equal(3, count); }
public void CreateEntity() { var expected = Dummy.Foos.ToArray(); var reader = Dummy.CreateDataReader(expected); var mapping = Dummy.EntityMapping; var test = new EntityReader<Foo>(reader, mapping); var actual = new List<Foo>(); while (test.Read()) { actual.Add(test.CreateEntity()); } Assert.Equal(expected, actual.ToArray()); }
public async Task Location_LocationTimeRecurring_Read() { var reader = new EntityReader <LocationTimeRecurring>(); var testEntity = new LocationTimeRecurring(); var lastKey = Defaults.Guid; await Location_LocationTimeRecurring_Create(); lastKey = LocationTimeRecurringTests.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 async Task Entity_CustomerInfo_Read() { var testEntity = new CustomerInfo(); var reader = new EntityReader <CustomerInfo>(); var lastKey = Defaults.Guid; await Entity_CustomerInfo_Create(); lastKey = CustomerEntityTests.RecycleBin.Last(); 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 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 async Task Venture_VentureLocation_Read() { var reader = new EntityReader <VentureLocation>(); var testEntity = new VentureLocation(); var lastKey = Defaults.Guid; await Venture_VentureLocation_Create(); lastKey = VentureLocationTests.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 async Task Schedule_ScheduleSlot_Read() { var reader = new EntityReader <ScheduleSlot>(); var testEntity = new ScheduleSlot(); var lastKey = Defaults.Guid; await Schedule_ScheduleSlot_Create(); lastKey = ScheduleSlotTests.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); Assert.IsTrue(!testEntity.FailedRules.Any()); }
public async Task Business_BusinessInfo_Read() { var reader = new EntityReader <BusinessInfo>(); var testEntity = new BusinessInfo(); var lastKey = Defaults.Guid; await Business_BusinessInfo_Create(); lastKey = BusinessInfoTests.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); Assert.IsTrue(!testEntity.FailedRules.Any()); }
public async Task Schedule_ScheduleSlot_Create() { var testEntity = new ScheduleSlot(); var resultEntity = new ScheduleSlot(); var reader = new EntityReader <ScheduleSlot>(); var scheduleTest = new ScheduleInfoTests(); var slotTest = new SlotInfoTests(); // Create base records await scheduleTest.Schedule_ScheduleInfo_Create(); testEntity.ScheduleKey = ScheduleInfoTests.RecycleBin.LastOrDefault(); await slotTest.Schedule_SlotInfo_Create(); testEntity.SlotKey = SlotInfoTests.RecycleBin.LastOrDefault(); // Create should update original object, and pass back a fresh-from-db object using (var writer = new EntityWriter <ScheduleSlot>(testEntity, new ScheduleSlotSPConfig())) { resultEntity = await writer.SaveAsync(); } Assert.IsTrue(testEntity.Id != Defaults.Integer); Assert.IsTrue(testEntity.Key != Defaults.Guid); Assert.IsTrue(resultEntity.Id != Defaults.Integer); Assert.IsTrue(resultEntity.Key != Defaults.Guid); Assert.IsTrue(!resultEntity.FailedRules.Any()); // 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); Assert.IsTrue(!testEntity.FailedRules.Any()); ScheduleSlotTests.RecycleBin.Add(testEntity.Key); }
public async Task Appointment_AppointmentInfo_Create() { var testEntity = new AppointmentInfo(); var resultEntity = new AppointmentInfo(); var reader = new EntityReader <AppointmentInfo>(); var locationTest = new LocationInfoTests(); var locationKey = Defaults.Guid; // Location is required await locationTest.Location_LocationInfo_Create(); locationKey = LocationInfoTests.RecycleBin.Last(); Assert.IsTrue(locationKey != Defaults.Guid); // 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 <AppointmentInfo>(testEntity, new AppointmentInfoSPConfig())) { resultEntity = await writer.SaveAsync(); } Assert.IsTrue(testEntity.Id != Defaults.Integer); Assert.IsTrue(testEntity.Key != Defaults.Guid); Assert.IsTrue(resultEntity.Id != Defaults.Integer); Assert.IsTrue(resultEntity.Key != Defaults.Guid); Assert.IsTrue(!resultEntity.FailedRules.Any()); // 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); Assert.IsTrue(!testEntity.FailedRules.Any()); AppointmentInfoTests.RecycleBin.Add(testEntity.Key); }