public void Ignores_no_change_to_principal_key_in_sidecar() { var notifierMock = new Mock <StateEntryNotifier>(); var model = BuildModel(); var contextServices = CreateContextServices(notifierMock.Object, model); var stateManager = contextServices.GetRequiredService <StateManager>(); var entityType = model.GetEntityType(typeof(Category)); var keyProperty = entityType.GetProperty("PrincipalId"); var category = new Category { Id = -1, PrincipalId = 77 }; var principalEntry = stateManager.StartTracking(stateManager.GetOrCreateEntry(category)); principalEntry.RelationshipsSnapshot[keyProperty] = 77; principalEntry.EntityState = EntityState.Added; var changeDetector = new ChangeDetector(new DbContextService <IModel>(model)); Assert.Same(principalEntry, stateManager.TryGetEntry(new SimpleEntityKey <int>(entityType, -1))); principalEntry.AddSidecar(new StoreGeneratedValuesFactory().Create(principalEntry))[keyProperty] = 77; changeDetector.PropertyChanged(principalEntry, keyProperty); notifierMock.Verify(m => m.PrincipalKeyPropertyChanged( It.IsAny <StateEntry>(), It.IsAny <IProperty>(), It.IsAny <object>(), It.IsAny <object>()), Times.Never); Assert.Equal(77, principalEntry.RelationshipsSnapshot[keyProperty]); Assert.Same(principalEntry, stateManager.TryGetEntry(new SimpleEntityKey <int>(entityType, -1))); }
/// <summary> /// Asynchronously saves all changes made in this context to the database. /// </summary> /// <param name="acceptAllChangesOnSuccess"> /// Indicates whether <see cref="ChangeTracking.ChangeTracker.AcceptAllChanges" /> is called after the changes have /// been sent successfully to the database. /// </param> /// <remarks> /// <para> /// This method will automatically call <see cref="ChangeTracking.ChangeTracker.DetectChanges" /> to discover any /// changes to entity instances before saving to the underlying database. This can be disabled via /// <see cref="ChangeTracking.ChangeTracker.AutoDetectChangesEnabled" />. /// </para> /// <para> /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure /// that any asynchronous operations have completed before calling another method on this context. /// </para> /// </remarks> /// <param name="cancellationToken">A <see cref="CancellationToken" /> to observe while waiting for the task to complete.</param> /// <returns> /// A task that represents the asynchronous save operation. The task result contains the /// number of state entries written to the database. /// </returns> public virtual async Task <int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default(CancellationToken)) { var stateManager = StateManager; if (ChangeTracker.AutoDetectChangesEnabled) { ChangeDetector.DetectChanges(stateManager); } try { return(await stateManager.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken)); } catch (Exception exception) { _logger.LogError( CoreLoggingEventId.DatabaseError, () => new DatabaseErrorLogState(GetType()), exception, e => CoreStrings.LogExceptionDuringSaveChanges(Environment.NewLine, e)); throw; } }
public void Reacts_to_principal_key_change_in_sidecar() { var model = BuildModel(); var configuration = TestHelpers.CreateContextConfiguration(model); var stateManager = configuration.Services.StateManager; var entityType = model.GetEntityType(typeof(Category)); var keyProperty = entityType.GetProperty("PrincipalId"); var category = new Category { Id = -1, PrincipalId = 77 }; var principalEntry = stateManager.StartTracking(stateManager.GetOrCreateEntry(category)); principalEntry.RelationshipsSnapshot[keyProperty] = 77; principalEntry.EntityState = EntityState.Added; var notifierMock = new Mock <StateEntryNotifier>(); var changeDetector = new ChangeDetector(configuration, notifierMock.Object); Assert.Same(principalEntry, stateManager.TryGetEntry(new SimpleEntityKey <int>(entityType, -1))); principalEntry.AddSidecar(new StoreGeneratedValuesFactory().Create(principalEntry))[keyProperty] = 78; changeDetector.SidecarPropertyChanged(principalEntry, keyProperty); notifierMock.Verify(m => m.PrincipalKeyPropertyChanged(principalEntry, keyProperty, 77, 78)); Assert.Equal(78, principalEntry.RelationshipsSnapshot[keyProperty]); Assert.Same(principalEntry, stateManager.TryGetEntry(new SimpleEntityKey <int>(entityType, -1))); }
public void Ignores_non_principal_key_change_in_sidecar() { var model = BuildModel(); var configuration = TestHelpers.CreateContextConfiguration(model); var stateManager = configuration.Services.StateManager; var entityType = model.GetEntityType(typeof(Category)); var property = entityType.GetProperty("Name"); var category = new Category { Id = -1, Name = "Blue" }; var principalEntry = stateManager.StartTracking(stateManager.GetOrCreateEntry(category)); principalEntry.RelationshipsSnapshot[property] = "Blue"; principalEntry.EntityState = EntityState.Added; var notifierMock = new Mock <StateEntryNotifier>(); var changeDetector = new ChangeDetector(configuration, notifierMock.Object); Assert.Same(principalEntry, stateManager.TryGetEntry(new SimpleEntityKey <int>(entityType, -1))); principalEntry.AddSidecar(new StoreGeneratedValuesFactory().Create(principalEntry))[property] = "Red"; changeDetector.SidecarPropertyChanged(principalEntry, property); notifierMock.Verify(m => m.PrincipalKeyPropertyChanged( It.IsAny <StateEntry>(), It.IsAny <IProperty>(), It.IsAny <object>(), It.IsAny <object>()), Times.Never); Assert.Equal("Blue", principalEntry.RelationshipsSnapshot[property]); Assert.Same(principalEntry, stateManager.TryGetEntry(new SimpleEntityKey <int>(entityType, -1))); }
public void Ignores_no_change_to_principal_key() { var model = BuildModel(); var configuration = TestHelpers.CreateContextConfiguration(model); var stateManager = configuration.Services.StateManager; var entityType = model.GetEntityType(typeof(Category)); var keyProperty = entityType.GetProperty("PrincipalId"); var category = new Category { Id = -1, PrincipalId = 77 }; var principalEntry = stateManager.StartTracking(stateManager.GetOrCreateEntry(category)); principalEntry.RelationshipsSnapshot[keyProperty] = 77; principalEntry.EntityState = EntityState.Added; var notifierMock = new Mock <StateEntryNotifier>(); var changeDetector = new ChangeDetector(configuration, notifierMock.Object); Assert.Same(principalEntry, stateManager.TryGetEntry(new SimpleEntityKey <int>(entityType, -1))); changeDetector.PropertyChanged(principalEntry, keyProperty); notifierMock.Verify(m => m.PrincipalKeyPropertyChanged( It.IsAny <StateEntry>(), It.IsAny <IProperty>(), It.IsAny <object>(), It.IsAny <object>()), Times.Never); Assert.Equal(77, principalEntry.RelationshipsSnapshot[keyProperty]); Assert.Same(principalEntry, stateManager.TryGetEntry(new SimpleEntityKey <int>(entityType, -1))); }
public void Detects_primary_key_change() { var model = BuildModel(); var configuration = TestHelpers.CreateContextConfiguration(model); var stateManager = configuration.Services.StateManager; var entityType = model.GetEntityType(typeof(Category)); var keyProperty = entityType.GetProperty("Id"); var category = new Category { Id = -1 }; var principalEntry = stateManager.StartTracking(stateManager.GetOrCreateEntry(category)); principalEntry.RelationshipsSnapshot[keyProperty] = -1; principalEntry.EntityState = EntityState.Added; var notifierMock = new Mock <StateEntryNotifier>(); var changeDetector = new ChangeDetector(configuration, notifierMock.Object); Assert.Same(principalEntry, stateManager.TryGetEntry(new SimpleEntityKey <int>(entityType, -1))); category.Id = 1; changeDetector.PropertyChanged(principalEntry, keyProperty); notifierMock.Verify(m => m.PrincipalKeyPropertyChanged(principalEntry, keyProperty, -1, 1)); Assert.Equal(1, principalEntry.RelationshipsSnapshot[keyProperty]); Assert.Same(principalEntry, stateManager.TryGetEntry(new SimpleEntityKey <int>(entityType, 1))); }
public void GetChangesRecursively_DifferentDeepVeryDifferentObjects_HasProperChanges() { var changes = ChangeDetector .GetChanges( new ComplexObject() { StringValue = "foo", MyIntValue = 28, SubObject = new ComplexObject() { StringValue = "bar", MyIntValue = 123 } }, new ComplexObject() { StringValue = "fuz", MyIntValue = 1337, SubObject = new ComplexObject() { StringValue = "baz", MyIntValue = 123 } }) .OrderBy(x => x.PropertyPath) .ToArray(); Assert.AreEqual(3, changes.Length); Assert.AreEqual(new Change("MyIntValue", 28, 1337), changes[0]); Assert.AreEqual(new Change("StringValue", "foo", "fuz"), changes[1]); Assert.AreEqual(new Change("SubObject.StringValue", "bar", "baz"), changes[2]); }
public void Ignores_non_principal_key_change() { var notifierMock = new Mock <StateEntryNotifier>(); var model = BuildModel(); var contextServices = CreateContextServices(notifierMock.Object, model); var stateManager = contextServices.GetRequiredService <StateManager>(); var entityType = model.GetEntityType(typeof(Category)); var property = entityType.GetProperty("Name"); var category = new Category { Id = -1, Name = "Blue" }; var principalEntry = stateManager.StartTracking(stateManager.GetOrCreateEntry(category)); principalEntry.RelationshipsSnapshot[property] = "Blue"; principalEntry.EntityState = EntityState.Added; var changeDetector = new ChangeDetector(new DbContextService <IModel>(model)); Assert.Same(principalEntry, stateManager.TryGetEntry(new SimpleEntityKey <int>(entityType, -1))); category.Name = "Red"; changeDetector.PropertyChanged(principalEntry, property); notifierMock.Verify(m => m.PrincipalKeyPropertyChanged( It.IsAny <StateEntry>(), It.IsAny <IProperty>(), It.IsAny <object>(), It.IsAny <object>()), Times.Never); Assert.Equal("Blue", principalEntry.RelationshipsSnapshot[property]); Assert.Same(principalEntry, stateManager.TryGetEntry(new SimpleEntityKey <int>(entityType, -1))); }
public void GetChangesRecursively_DifferentSubObjectCollectionsInDeepObjects_HasChange() { var changes = ChangeDetector .GetChanges( new DeepComplexObject() { ComplexObject = new ComplexObject() { SubObjects = new List <ComplexObject>() } }, new DeepComplexObject() { ComplexObject = new ComplexObject() { SubObjects = new List <ComplexObject>() { new ComplexObject() } } }); Assert.AreEqual(4, changes.Count); Assert.IsTrue(changes.HasChangeFor(x => x.ComplexObject.SubObjects)); }
public void Detects_principal_key_change() { var notifierMock = new Mock <StateEntryNotifier>(); var model = BuildModel(); var contextServices = CreateContextServices(notifierMock.Object, model); var stateManager = contextServices.GetRequiredService <StateManager>(); var entityType = model.GetEntityType(typeof(Category)); var keyProperty = entityType.GetProperty("PrincipalId"); var category = new Category { Id = -1, PrincipalId = 77 }; var principalEntry = stateManager.StartTracking(stateManager.GetOrCreateEntry(category)); principalEntry.RelationshipsSnapshot[keyProperty] = 77; principalEntry.EntityState = EntityState.Added; var changeDetector = new ChangeDetector(new DbContextService <IModel>(model)); Assert.Same(principalEntry, stateManager.TryGetEntry(new SimpleEntityKey <int>(entityType, -1))); category.PrincipalId = 78; changeDetector.PropertyChanged(principalEntry, keyProperty); notifierMock.Verify(m => m.PrincipalKeyPropertyChanged(principalEntry, keyProperty, 77, 78)); Assert.Equal(78, principalEntry.RelationshipsSnapshot[keyProperty]); Assert.Same(principalEntry, stateManager.TryGetEntry(new SimpleEntityKey <int>(entityType, -1))); }
public static void FindAndDisplayChanges(PSMSchema schemaVersion1, PSMSchema schemaVersion2) { ChangeDetector changeDetector = new ChangeDetector(); DetectedChangeInstancesSet detectedChangeInstancesSet = changeDetector.DetectChanges(schemaVersion1, schemaVersion2); EvolutionChangesWindow.Show(detectedChangeInstancesSet, Current.MainWindow, schemaVersion1.PSMDiagram, schemaVersion2.PSMDiagram); }
public static void Adapt(PSMSchema schemaVersion1, PSMSchema schemaVersion2) { ChangeDetector changeDetector = new ChangeDetector(); DetectedChangeInstancesSet detectedChangeInstancesSet = changeDetector.DetectChanges(schemaVersion1, schemaVersion2); XsltAdaptationScriptGenerator g = new XsltAdaptationScriptGenerator(); g.Initialize(schemaVersion1, schemaVersion2, detectedChangeInstancesSet); g.GenerateTransformationStructure(); XDocument revalidationStylesheet = g.GetAdaptationTransformation(); revalidationStylesheet.Elements().First().AddFirst(new XComment(string.Format(" Template generated by eXolutio on {0} {1} \r\n from {2}. ", System.DateTime.Now.ToShortDateString(), System.DateTime.Now.ToShortTimeString(), Current.Project.ProjectFile))); if (Environment.MachineName.Contains("TRUPIK")) { revalidationStylesheet.Save(XsltTestWindow.SAVE_STYLESHEET); if (schemaVersion1.Project.ProjectFile != null) { string ls = string.Format("{0}\\{1}", schemaVersion1.Project.ProjectFile.Directory.FullName, "LastStylesheet.xslt"); revalidationStylesheet.Save(ls); } } //else { XsltTestWindow.ShowDialog(detectedChangeInstancesSet, schemaVersion1, schemaVersion2); } }
private void TryDetectChanges(IStateManager stateManager) { if (ChangeTracker.AutoDetectChangesEnabled) { ChangeDetector.DetectChanges(stateManager); } }
private void ChangeDetector_Tick(object sender, EventArgs e) { PreviousName = null; ChangeDetector.Stop(); if (ReadyToSearchAgain != null) { ReadyToSearchAgain(); } }
public void HasChangedRecursively_SameSameShallowObjects_ReturnsFalse() { Assert.IsFalse(ChangeDetector.HasChanges(new ComplexObject() { StringValue = "foo" }, new ComplexObject() { StringValue = "foo" })); }
public void HasChangedRecursively_DifferentShallowObjects_ReturnsTrue() { Assert.IsTrue(ChangeDetector.HasChanges(new ComplexObject() { StringValue = "foo" }, new ComplexObject() { StringValue = "bar" })); }
public ChangeDetector_Tests() { sut = new ChangeDetector(); originalObject = new SimplePoco() { ID = 30, name = "Name", boolean = true, date = DateTime.MinValue, number = 42 }; changedObject = new SimplePoco() { ID = 30, name = "Kyle", boolean = true, date = DateTime.MinValue, number = 42 }; }
private void DiscoveryTimer_Tick(object sender, EventArgs e) { var a = new DiscoveryArguments(); if (TimeToCheckForUnknownRecipients != null) { TimeToCheckForUnknownRecipients(a); } if (string.IsNullOrEmpty(a.Name)) { return; } if (PreviousName != null) { if (PreviousName == a.Name) { return; } } if (!ChangeDetector.Enabled) { PreviousName = a.Name; ChangeDetector.Start(); } var NameFound = false; foreach (var k in a.Configuration) { if (k.Name == a.Name) { NameFound = true; break; } } if (NameFound) { return; } AskNameFromPeers(a); }
public void HasChangesRecursively_RecursiveObjects_ReturnsFalse() { var recursiveObject1 = new RecursiveObject(); recursiveObject1.Reference = recursiveObject1; var recursiveObject2 = new RecursiveObject(); recursiveObject2.Reference = recursiveObject2; Assert.IsFalse(ChangeDetector.HasChanges( recursiveObject1, recursiveObject2)); }
protected override void ScenarioSetup() { Entity = (Entity)Context.Create <IProduct>(rdfs.Class).Unwrap(); ChangeDetector.Setup(instance => instance.Process(It.IsAny <Entity>(), It.IsAny <IDictionary <IEntity, ISet <Statement> > >(), It.IsAny <IDictionary <IEntity, ISet <Statement> > >())) .Callback <Entity, IDictionary <IEntity, ISet <Statement> >, IDictionary <IEntity, ISet <Statement> > >((entity, retracted, added) => { RetractedStatements = retracted; AddedStatements = added; }); DeletedEntities = new List <Iri>(); EntitySource.Setup(instance => instance.Commit( It.IsAny <IEnumerable <Iri> >(), It.IsAny <IDictionary <IEntity, ISet <Statement> > >(), It.IsAny <IDictionary <IEntity, ISet <Statement> > >())); }
public void AdbisExample() { ProjectSerializationManager s = new ProjectSerializationManager(); DirectoryInfo pd = new DirectoryInfo(Environment.CurrentDirectory); while (!pd.GetDirectories().Any(d => d.FullName.EndsWith(@"Projects"))) { pd = pd.Parent; } Project p = s.LoadProject(Path.Combine(pd.FullName, "Projects", "adbis-branched.eXo")); ChangeDetector detector = new ChangeDetector(); DetectedChangeInstancesSet detectedChangeInstancesSet = detector.DetectChanges(p.ProjectVersions[0].PSMSchemas[0], p.ProjectVersions[1].PSMSchemas[0]); }
public void GetChangesRecursively_StringHashSet_HasProperChanges() { var oldObject = new HashSet <string>(new [] { "foo", "bar", "baz", "fuz" }); var newObject = new HashSet <string>(new [] { "foo", "lol", "hi", "fuz" }); var changes = ChangeDetector .GetChanges( oldObject, newObject) .OrderBy(x => x.PropertyPath) .ToArray(); Assert.AreEqual(3, changes.Length); Assert.AreEqual(new Change("", oldObject, newObject), changes[0]); Assert.AreEqual(new Change("1", "bar", "lol"), changes[1]); Assert.AreEqual(new Change("2", "baz", "hi"), changes[2]); }
public async Task FileChangeDetectTest() { using var hashAlgorithm = System.Security.Cryptography.SHA1.Create(); using var testStream = new MemoryStream(new byte[] { 1, 2, 3 }); using var writer = new StreamWriter(testStream); using var hashStream = new MemoryStream(hashAlgorithm.ComputeHash(new byte[] { 1, 2, 3 })); var changeDetector = new ChangeDetector(hashAlgorithm); Assert.Null(await changeDetector.DetectAsync(file: testStream, hash: hashStream).ConfigureAwait(false)); testStream.Position = 0; await writer.WriteAsync('.').ConfigureAwait(false); await writer.FlushAsync().ConfigureAwait(false); Assert.NotNull(await changeDetector.DetectAsync(file: testStream, hash: hashStream).ConfigureAwait(false)); }
public void GetChangesRecursively_ComplexObjectToNullSubObject_HasProperChanges() { var oldObject = new ComplexObject() { StringValue = "foo", MyIntValue = 28, SubObject = new ComplexObject() { StringValue = "baz", MyIntValue = 123 } }; var newObject = new ComplexObject() { StringValue = "fuz", MyIntValue = 1337, SubObject = null }; var changeCollection = ChangeDetector .GetChanges( oldObject, newObject); var changes = changeCollection .OrderBy(x => x.PropertyPath) .ToArray(); Assert.AreEqual(6, changes.Length); Assert.AreEqual(new Change("MyIntValue", 28, 1337), changes[0]); Assert.AreEqual(new Change("StringValue", "foo", "fuz"), changes[1]); Assert.AreEqual(new Change("SubObject.MyIntValue", 123, null), changes[2]); Assert.AreEqual(new Change("SubObject.StringsHashSet", oldObject.SubObject.StringsHashSet, null), changes[3]); Assert.AreEqual(new Change("SubObject.StringsHashSet.0", "foo", null), changes[4]); Assert.AreEqual(new Change("SubObject.StringValue", "baz", null), changes[5]); Assert.IsTrue(changeCollection.HasChangeFor(x => x.SubObject.StringsHashSet)); }
public void GetChangesRecursively_SubObjectNullDifferences_HasChange() { var changes = ChangeDetector .GetChanges( new DeepComplexObject() { ComplexObject = new ComplexObject() { EnumHashSet = null } }, new DeepComplexObject() { ComplexObject = new ComplexObject() { EnumHashSet = new HashSet <SimpleEnum>() { SimpleEnum.Foo } } }); Assert.AreEqual(2, changes.Count); }
public void TestOCLAdaptation(object directory) { DirectoryInfo testDir = new DirectoryInfo(directory.ToString()); try { FileInfo[] inputFiles = testDir.GetFiles("*in.xml"); FileInfo projectFile = testDir.GetFiles("*.eXo").FirstOrDefault(); if (projectFile == null) { Assert.Fail("No project file found for test {0}", testDir.Name); } FileInfo[] stylesheetFiles = testDir.GetFiles("*.xslt"); FileInfo referenceStylesheetFileInfo = null; foreach (FileInfo stylesheetFile in stylesheetFiles) { if (stylesheetFile.Name.Contains("DesiredStylesheet") || stylesheetFile.Name.Contains("LastStylesheet") || stylesheetFile.Name.Contains("generated") || stylesheetFile.Name.Contains("last-working")) { continue; } referenceStylesheetFileInfo = stylesheetFile; } Project project = serializationManager.LoadProject(projectFile); XsltAdaptationScriptGenerator generator = new XsltAdaptationScriptGenerator(); ChangeDetector detector = new ChangeDetector(); PSMSchema psmSchemaOldVersion = project.ProjectVersions[0].PSMSchemas.First(); PSMSchema psmSchemaNewVersion = project.ProjectVersions[1].PSMSchemas.First(); DetectedChangeInstancesSet detectedChangeInstancesSet = detector.DetectChanges(psmSchemaOldVersion, psmSchemaNewVersion); generator.Initialize(psmSchemaOldVersion, psmSchemaNewVersion, detectedChangeInstancesSet); generator.SchemaAware = true; generator.GenerateTransformationStructure(); XDocument testGeneratedStylesheet = generator.GetAdaptationTransformation(); string testGeneratedStylesheetFileName = testDir.FullName + "/" + testDir.Name + "-generated.xslt"; testGeneratedStylesheet.SaveInUtf8(testGeneratedStylesheetFileName); Console.WriteLine("Revalidation stylesheet generated."); Console.WriteLine(); string generatedStylesheetText = File.ReadAllText(testGeneratedStylesheetFileName); StringBuilder failMessage = new StringBuilder(); int failCounts = 0; StringBuilder inconclusiveMessage = new StringBuilder(); if (referenceStylesheetFileInfo != null) { //XDocument xdRefStylesheet = XDocument.Load(referenceStylesheet.FullName); //xdRefStylesheet.RemoveComments(); //string referenceStylesheetText = xdRefStylesheet.ToString(); //XDocument xdGenStylesheet = XDocument.Load(testGeneratedStylesheetFile); //xdGenStylesheet.RemoveComments(); //generatedStylesheetText = xdGenStylesheet.ToString(); string diff; if (XmlDocumentHelper.DocumentCompare(testGeneratedStylesheetFileName, referenceStylesheetFileInfo.FullName, out diff, XmlDiffOptions.IgnoreComments | XmlDiffOptions.IgnoreWhitespace)) { string message = string.Format("Generated stylesheet for {1} is identical to reference stylesheet {0}.", referenceStylesheetFileInfo.Name, testDir.Name); Console.WriteLine(message); } else { string message = string.Format("Generated stylesheet for {1} differs from reference stylesheet {0}.", referenceStylesheetFileInfo.Name, testDir.Name); Console.WriteLine(message); inconclusiveMessage.AppendLine(message); } } else { string message = string.Format("No reference stylesheet available. "); Console.WriteLine(message); } Console.WriteLine(); string tmpDir = Path.GetTempPath(); foreach (FileInfo inputFile in inputFiles) { Console.WriteLine("Testing revalidation of file {0}.", inputFile.Name); string input = File.ReadAllText(inputFile.FullName); string output = XsltProcessing.TransformSAXON(inputFile.FullName, testGeneratedStylesheetFileName, true); string genOutputFile = inputFile.FullName.Replace("in.xml", "out-generated.xml"); File.WriteAllText(genOutputFile, output); Console.WriteLine("XSLT transformation succeeded, results written to {0}. ", genOutputFile); string refOutputFile = inputFile.FullName.Replace("in.xml", "out.xml"); if (File.Exists(refOutputFile)) { bool bIdentical = XmlDocumentHelper.DocumentCompare(refOutputFile, genOutputFile, XmlDiffOptions.IgnoreXmlDecl | XmlDiffOptions.IgnoreComments); if (bIdentical) { string message = string.Format("Output for file {0} is identical to the reference output. ", inputFile.Name); Console.WriteLine(message); } else { string message = string.Format("Result differs from reference output for file {0}", inputFile.Name); Console.WriteLine(message); failMessage.AppendLine(message); failCounts++; } } else { string message = string.Format("Reference output not found for file {0}", inputFile.Name); Console.WriteLine(message); inconclusiveMessage.AppendLine(message); } } if (inputFiles.Length == 0) { string message = string.Format("No input files for test {0}", testDir.Name); Console.WriteLine(message); inconclusiveMessage.AppendLine(message); } if (failCounts > 0) { string finalMessage = string.Format("Failed for {0}/{1} test inputs. \r\n", failCounts, inputFiles.Length); Console.WriteLine(finalMessage); failMessage.Insert(0, finalMessage); Assert.Fail(failMessage.ToString()); } if (inconclusiveMessage.Length > 0) { Assert.Inconclusive(inconclusiveMessage.ToString()); } if (failCounts == 0) { string lastWorkingStylesheetFile = testDir.FullName + "/" + testDir.Name + "-last-working.xslt"; testGeneratedStylesheet.SaveInUtf8(lastWorkingStylesheetFile); } Console.WriteLine("Test succeeded. "); } catch (Exception exception) { } }
public void HasChangedRecursively_NullAndString_ReturnsTrue() { Assert.IsTrue(ChangeDetector.HasChanges(null, "foo")); }
private ChangeDetector CreateChangeDetector(object obj) { return(ChangeDetector.Create(obj, () => StateHasChanged++)); }
/// <summary> /// Scans the tracked entity instances to detect any changes made to the instance data. <see cref="DetectChanges()" /> /// is usually called automatically by the context when up-to-date information is required (before /// <see cref="DbContext.SaveChanges()" /> and when returning change tracking information). You typically only need to /// call this method if you have disabled <see cref="AutoDetectChangesEnabled" />. /// </summary> public virtual void DetectChanges() => ChangeDetector.DetectChanges(StateManager);
public void HasChangedRecursively_Nulls_ReturnsFalse() { Assert.IsFalse(ChangeDetector.HasChanges(null, null)); }