Exemple #1
0
        public void FullUpdate() //Lots of tests with updating
        {
            var package            = SimplePackage();
            var originaPackageCopy = new EntityPackage(package);

            service.InsertWithHistoryAsync(package, 1).Wait();

            var firstInsertedPackage = new EntityPackage(package);

            package.Relations.First().value = "Something NEW";
            package.Values.First().value    = "aha MORE";

            service.UpdateWithHistoryAsync(package, 1).Wait();

            //This shouldn't be "new", it should be the same as before
            Assert.Equal(firstInsertedPackage.Entity.id, package.Entity.id);

            var revisions = service.GetRevisionIdsAsync(package.Entity.id).Result;

            Assert.Single(revisions);
            Assert.NotEqual(package.Entity.id, revisions.First());

            //Ensure the CURRENT package we pulled out is EXACTLY the same (minus date kind)
            var currentPackage = provider.FindByIdAsync(package.Entity.id).Result;

            Assert.Equal(package, currentPackage);

            //Ensure the package from history is EXACTLY the same as the one before sans ids (set all to 0)
            var revisionPackage = provider.FindByIdAsync(revisions.First()).Result;
            var likeUpdate      = service.ConvertHistoryToUpdate(revisionPackage);

            Assert.Equal(firstInsertedPackage, likeUpdate);
        }