public async Task Entity_EntityLocation_Create() { var testEntity = new EntityLocation(); var resultEntity = new EntityLocation(); var reader = new EntityReader <EntityLocation>(); var testClass = new PersonInfoTests(); var testClassLocation = new LocationInfoTests(); // Create Entity await testClass.Person_PersonInfo_Create(); await testClassLocation.Location_LocationInfo_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(); testEntity.LocationKey = LocationInfoTests.RecycleBin.LastOrDefault(); using (var writer = new EntityWriter <EntityLocation>(testEntity, new EntityLocationSPConfig())) { 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); EntityLocationTests.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); }