public void CanApplyLocalCopyOfPartialUpdateToExistingRecord() { //Given var zipStreamProcesser = new FakeZipStreamProcesser(PartialMasterUpdatePath); var masterDataUpdater = new MasterDataUpdater(Database, zipStreamProcesser); var assetType = new AssetType() { Id = new Guid("202fc04f-40be-4297-96ff-a375630c805c"), Name = "Current Name" }; Database.Update(assetType); //When var result = masterDataUpdater.ApplyUpdate(true, default(Stream)); //Then CheckResult(result); var count = Database.Count(typeof(AssetType)); Assert.AreEqual(1, count, "should only have one record for Asset Type"); var assetTypeFromDb = Database.Table<AssetType>().FirstOrDefault(); Assert.AreEqual(assetType.Id, assetTypeFromDb.Id, "Guids do not match"); //COOLER TYPE is present in the record in MasterDataFiles/Partial/AssetType_0.csv Assert.AreEqual("COOLER TYPE", assetTypeFromDb.Name, "Name has not been updated"); }
public void CanApplyLocalCopyOfFullMasterDataUpdate() { //Given var zipStreamProcesser = new FakeZipStreamProcesser(FullMasterUpdatePath); var masterDataUpdater = new MasterDataUpdater(Database, zipStreamProcesser); //When var result = masterDataUpdater.ApplyUpdate(false, default(Stream)); //Then CheckResult(result); var actualTableNames = new List<string>(); var emptyTables = new List<string>(); foreach (var entity in DatabaseConfig.GetMasteDataTypes()) { var tableName = Database.GetTableName(entity); actualTableNames.Add(tableName); var count = Database.Count(entity); if (count == 0) emptyTables.Add(tableName); } var fail = CheckEmpty("Local Tables that have no rows:\n{0}", emptyTables); var difference = actualTableNames.Except(zipStreamProcesser.TableNames); fail += CheckEmpty("Local Tables that have no Master Data CSV File:\n{0}", difference); difference = zipStreamProcesser.TableNames.Except(actualTableNames); fail += CheckEmpty("Master Data CSV Files without Local Tables:\n {0}", difference); Assert.IsTrue(fail == 0, "\n\nOne or more errors occurred"); }
public void LoadDatabase() { //This reuses some of the actual application code, which I am not 100% comfortable with. At least this code is tested by MasterDataUpdaterTest //when running on a CI server I hope to make MasterDataUpdaterTest run first, and then not run any WithFullDatbaseTest child tests if it is unsuccesful var zipStreamProcesser = new FakeZipStreamProcesser(MasterDataUpdaterTest.FullMasterUpdatePath); var masterDataUpdater = new MasterDataUpdater(Database, zipStreamProcesser); var result = masterDataUpdater.ApplyUpdate(false, default(Stream)); if (!result.WasSuccessful()) { throw result.Exception; } }