Ejemplo n.º 1
0
        public async Task Schedule_SlotResource_Create()
        {
            var testEntity   = new SlotResource();
            var resultEntity = new SlotResource();
            var reader       = new EntityReader <SlotResource>();
            var SlotTest     = new SlotInfoTests();

            // Create a base record
            await SlotTest.Schedule_SlotInfo_Create();

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

            SlotResourceTests.RecycleBin.Add(testEntity.Key);
        }
Ejemplo n.º 2
0
        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);
        }