public void SanityCheck_VersionComment() { CatalogDto priceListDto = new CatalogDto() { CatalogTitle = Rand.AnyTitle, CatalogDesc = Rand.AnyDescription, }; int numItemsToAdd = 2; for (int i = 0; i < numItemsToAdd; ++i) { CatalogEntryDto productConfigDto = new CatalogEntryDto() { EntryTitle = Rand.AnyTitle, DisplayPrice = 100, SalePrice = 10, }.SetObjectAsReady() as CatalogEntryDto; priceListDto.CatalogItems.Add(productConfigDto); } // First version should get saved here: string comment0 = Rand.AnyComment; priceListDto.SetObjectAsReady(comment0); var versions = OdCepManager.Versioning.GetAllVersions(typeof(CatalogDto), priceListDto.Uuid); Assert.AreEqual(1, versions.Count, "Did not retrieve correct number of versions."); var kvPair = versions[0]; Assert.AreEqual(comment0, kvPair.Value, "Version comment not as expected."); }
public void SanityCheck_WithCollection() { CatalogDto priceListDto = new CatalogDto() { CatalogTitle = Rand.AnyTitle, CatalogDesc = Rand.AnyDescription, }; int numItemsToAdd = 2; for (int i = 0; i < numItemsToAdd; ++i) { CatalogEntryDto productConfigDto = new CatalogEntryDto() { EntryTitle = Rand.AnyTitle, DisplayPrice = 100, SalePrice = 10, }.SetObjectAsReady() as CatalogEntryDto; priceListDto.CatalogItems.Add(productConfigDto); } priceListDto.SetObjectAsReady(); // Let's retrieve the object now: string retrUuid = OdCepManager.Indexing.GetUuidForUniqueValue(typeof(CatalogDto), priceListDto.CatalogTitle); CatalogDto retrObj = (CatalogDto)OdCepManager.Versioning.GetHeadVersion(typeof(CatalogDto), retrUuid, out string comment); Assert.AreEqual(numItemsToAdd, retrObj.CatalogItems.Count(), "Does not show same number of objects as saved."); }
public void SanityCheck_NethVersions() { CatalogDto priceListDto = new CatalogDto() { CatalogTitle = Rand.AnyTitle, CatalogDesc = Rand.AnyDescription, }; int numItemsToAddBeforeReady = 2; // Since object is not ready yet, this will be the zeroeth version // regardless of the number of items that we add. for (int i = 0; i < numItemsToAddBeforeReady; ++i) { CatalogEntryDto productConfigDto = new CatalogEntryDto() { EntryTitle = Rand.AnyTitle, DisplayPrice = 100, SalePrice = 10, }.SetObjectAsReady() as CatalogEntryDto; priceListDto.CatalogItems.Add(productConfigDto); } // First version should get saved here: priceListDto.SetObjectAsReady(); int numItemsToAddAfterReady = 3; // Each item addition will result in a new version: for (int i = 0; i < numItemsToAddAfterReady; ++i) { CatalogEntryDto productConfigDto = new CatalogEntryDto() { EntryTitle = Rand.AnyTitle, DisplayPrice = 100, SalePrice = 10, }.SetObjectAsReady() as CatalogEntryDto; priceListDto.CatalogItems.Add(productConfigDto); } // At this point, there should be numItemsToAddAfterReady + 1 versions of PriceListDto. // 0eth version should have numItemsToAddBeforeReady items; // 1eth version should have numItemsToAddBeforeReady + 1 items; // 2eth version should have numItemsToAddBeforeReady + 2 items; // 3eth version should have numItemsToAddBeforeReady + 3 items; // Head version should have numItemsToAddBeforeReady + 3 items, same as 3eth version. string comment; CatalogDto p0 = (CatalogDto)OdCepManager.Versioning.GetNEthVersion(typeof(CatalogDto), priceListDto.Uuid, 0, out comment); Assert.AreEqual(numItemsToAddBeforeReady, p0.CatalogItems.Count, "Did not return correct number of items."); CatalogDto p1 = (CatalogDto)OdCepManager.Versioning.GetNEthVersion(typeof(CatalogDto), priceListDto.Uuid, 1, out comment); Assert.AreEqual(numItemsToAddBeforeReady + 1, p1.CatalogItems.Count, "Did not return correct number of items."); CatalogDto p2 = (CatalogDto)OdCepManager.Versioning.GetNEthVersion(typeof(CatalogDto), priceListDto.Uuid, 2, out comment); Assert.AreEqual(numItemsToAddBeforeReady + 2, p2.CatalogItems.Count, "Did not return correct number of items."); CatalogDto p3 = (CatalogDto)OdCepManager.Versioning.GetNEthVersion(typeof(CatalogDto), priceListDto.Uuid, 3, out comment); Assert.AreEqual(numItemsToAddBeforeReady + 3, p3.CatalogItems.Count, "Did not return correct number of items."); CatalogDto pH = (CatalogDto)OdCepManager.Versioning.GetHeadVersion(typeof(CatalogDto), priceListDto.Uuid, out comment); Assert.AreEqual(numItemsToAddBeforeReady + 3, pH.CatalogItems.Count, "Did not return correct number of items."); }