public void ExerciseBuildEventContext() { BuildEventContext parentBuildEventContext = new BuildEventContext(0, 0, 0, 0); BuildEventContext currentBuildEventContext = new BuildEventContext(0, 2, 1, 1); BuildEventContext currentBuildEventContextNode = new BuildEventContext(1, 0, 0, 0); BuildEventContext currentBuildEventContextTarget = new BuildEventContext(0, 1, 0, 0); BuildEventContext currentBuildEventContextPci = new BuildEventContext(0, 0, 1, 0); BuildEventContext currentBuildEventContextTask = new BuildEventContext(0, 0, 0, 1); BuildEventContext allDifferent = new BuildEventContext(1, 1, 1, 1); BuildEventContext allSame = new BuildEventContext(0, 0, 0, 0); ProjectStartedEventArgs startedEvent = new ProjectStartedEventArgs(-1, "Message", "HELP", "File", "Targets", null, null, parentBuildEventContext); startedEvent.BuildEventContext = currentBuildEventContext; Assert.IsTrue(parentBuildEventContext.GetHashCode() == 0); // Node is different Assert.IsFalse(parentBuildEventContext.Equals(currentBuildEventContextNode)); // Target is different Assert.IsFalse(parentBuildEventContext.Equals(currentBuildEventContextTarget)); // PCI is different Assert.IsFalse(parentBuildEventContext.Equals(currentBuildEventContextPci)); // Task is different Assert.IsFalse(parentBuildEventContext.Equals(currentBuildEventContextTask)); // All fields are different Assert.IsFalse(parentBuildEventContext.Equals(allDifferent)); // All fields are same Assert.IsTrue(parentBuildEventContext.Equals(allSame)); // Compare with null Assert.IsFalse(parentBuildEventContext.Equals(null)); // Compare with self Assert.IsTrue(currentBuildEventContext.Equals(currentBuildEventContext)); Assert.IsFalse(currentBuildEventContext.Equals(new object())); Assert.IsNotNull(startedEvent.BuildEventContext); Assert.AreEqual(0, startedEvent.ParentProjectBuildEventContext.NodeId); Assert.AreEqual(0, startedEvent.ParentProjectBuildEventContext.TargetId); Assert.AreEqual(0, startedEvent.ParentProjectBuildEventContext.ProjectContextId); Assert.AreEqual(0, startedEvent.ParentProjectBuildEventContext.TaskId); Assert.AreEqual(0, startedEvent.BuildEventContext.NodeId); Assert.AreEqual(2, startedEvent.BuildEventContext.TargetId); Assert.AreEqual(1, startedEvent.BuildEventContext.ProjectContextId); Assert.AreEqual(1, startedEvent.BuildEventContext.TaskId); }
public void ExerciseBuildEventContext() { BuildEventContext parentBuildEventContext = new BuildEventContext(0, 0, 0, 0, 0, 0, 0); BuildEventContext currentBuildEventContext = new BuildEventContext(0, 1, 2, 3, 4, 5, 6); BuildEventContext currentBuildEventContextSubmission = new BuildEventContext(1, 0, 0, 0, 0, 0, 0); BuildEventContext currentBuildEventContextNode = new BuildEventContext(0, 1, 0, 0, 0, 0, 0); BuildEventContext currentBuildEventContextEvaluation = new BuildEventContext(0, 0, 1, 0, 0, 0, 0); BuildEventContext currentBuildEventContextProjectInstance = new BuildEventContext(0, 0, 0, 1, 0, 0, 0); BuildEventContext currentBuildEventProjectContext = new BuildEventContext(0, 0, 0, 0, 1, 0, 0); BuildEventContext currentBuildEventContextTarget = new BuildEventContext(0, 0, 0, 0, 0, 1, 0); BuildEventContext currentBuildEventContextTask = new BuildEventContext(0, 0, 0, 0, 0, 0, 1); BuildEventContext allDifferent = new BuildEventContext(1, 1, 1, 1, 1, 1, 1); BuildEventContext allSame = new BuildEventContext(0, 0, 0, 0, 0, 0, 0); ProjectStartedEventArgs startedEvent = new ProjectStartedEventArgs(-1, "Message", "HELP", "File", "Targets", null, null, parentBuildEventContext); startedEvent.BuildEventContext = currentBuildEventContext; // submissison ID does not partake into equality Assert.Equal(parentBuildEventContext.GetHashCode(), currentBuildEventContextSubmission.GetHashCode()); Assert.NotEqual(parentBuildEventContext.GetHashCode(), currentBuildEventContext.GetHashCode()); Assert.NotEqual(parentBuildEventContext.GetHashCode(), currentBuildEventContextNode.GetHashCode()); Assert.NotEqual(parentBuildEventContext.GetHashCode(), currentBuildEventContextEvaluation.GetHashCode()); Assert.NotEqual(parentBuildEventContext.GetHashCode(), currentBuildEventContextProjectInstance.GetHashCode()); Assert.NotEqual(parentBuildEventContext.GetHashCode(), currentBuildEventProjectContext.GetHashCode()); Assert.NotEqual(parentBuildEventContext.GetHashCode(), currentBuildEventContextTarget.GetHashCode()); Assert.NotEqual(parentBuildEventContext.GetHashCode(), currentBuildEventContextTask.GetHashCode()); Assert.NotEqual(parentBuildEventContext.GetHashCode(), allDifferent.GetHashCode()); Assert.Equal(parentBuildEventContext.GetHashCode(), allSame.GetHashCode()); // submissison ID does not partake into equality Assert.Equal(parentBuildEventContext, currentBuildEventContextSubmission); Assert.NotEqual(parentBuildEventContext, currentBuildEventContext); Assert.NotEqual(parentBuildEventContext, currentBuildEventContextNode); Assert.NotEqual(parentBuildEventContext, currentBuildEventContextEvaluation); Assert.NotEqual(parentBuildEventContext, currentBuildEventContextProjectInstance); Assert.NotEqual(parentBuildEventContext, currentBuildEventProjectContext); Assert.NotEqual(parentBuildEventContext, currentBuildEventContextTarget); Assert.NotEqual(parentBuildEventContext, currentBuildEventContextTask); Assert.NotEqual(parentBuildEventContext, allDifferent); Assert.Equal(parentBuildEventContext, allSame); Assert.Equal(currentBuildEventContext, currentBuildEventContext); Assert.NotEqual(parentBuildEventContext, null); Assert.NotEqual(currentBuildEventContext, new object()); Assert.NotNull(startedEvent.BuildEventContext); Assert.Equal(0, startedEvent.ParentProjectBuildEventContext.SubmissionId); Assert.Equal(0, startedEvent.ParentProjectBuildEventContext.NodeId); Assert.Equal(0, startedEvent.ParentProjectBuildEventContext.EvaluationId); Assert.Equal(0, startedEvent.ParentProjectBuildEventContext.ProjectInstanceId); Assert.Equal(0, startedEvent.ParentProjectBuildEventContext.ProjectContextId); Assert.Equal(0, startedEvent.ParentProjectBuildEventContext.TargetId); Assert.Equal(0, startedEvent.ParentProjectBuildEventContext.TaskId); Assert.Equal(0, startedEvent.BuildEventContext.SubmissionId); Assert.Equal(1, startedEvent.BuildEventContext.NodeId); Assert.Equal(2, startedEvent.BuildEventContext.EvaluationId); Assert.Equal(3, startedEvent.BuildEventContext.ProjectInstanceId); Assert.Equal(4, startedEvent.BuildEventContext.ProjectContextId); Assert.Equal(5, startedEvent.BuildEventContext.TargetId); Assert.Equal(6, startedEvent.BuildEventContext.TaskId); }
public override int GetHashCode() { return(_entryPointContext.GetHashCode() + _targetName.GetHashCode()); }
public void ExerciseBuildEventContext() { BuildEventContext parentBuildEventContext = new BuildEventContext(0, 0, 0, 0, 0, 0, 0); BuildEventContext currentBuildEventContext = new BuildEventContext(0, 1, 2, 3, 4, 5, 6); BuildEventContext currentBuildEventContextSubmission = new BuildEventContext(1, 0, 0, 0, 0, 0, 0); BuildEventContext currentBuildEventContextNode = new BuildEventContext(0, 1, 0, 0, 0, 0, 0); BuildEventContext currentBuildEventContextEvaluation = new BuildEventContext(0, 0, 1, 0, 0, 0, 0); BuildEventContext currentBuildEventContextProjectInstance = new BuildEventContext(0, 0, 0, 1, 0, 0, 0); BuildEventContext currentBuildEventProjectContext = new BuildEventContext(0, 0, 0, 0, 1, 0, 0); BuildEventContext currentBuildEventContextTarget = new BuildEventContext(0, 0, 0, 0, 0, 1, 0); BuildEventContext currentBuildEventContextTask = new BuildEventContext(0, 0, 0, 0, 0, 0, 1); BuildEventContext allDifferent = new BuildEventContext(1, 1, 1, 1, 1, 1, 1); BuildEventContext allSame = new BuildEventContext(0, 0, 0, 0, 0, 0, 0); ProjectStartedEventArgs startedEvent = new ProjectStartedEventArgs(-1, "Message", "HELP", "File", "Targets", null, null, parentBuildEventContext); startedEvent.BuildEventContext = currentBuildEventContext; // submissison ID does not partake into equality currentBuildEventContextSubmission.GetHashCode().ShouldBe(parentBuildEventContext.GetHashCode()); currentBuildEventContext.GetHashCode().ShouldNotBe(parentBuildEventContext.GetHashCode()); currentBuildEventContextNode.GetHashCode().ShouldNotBe(parentBuildEventContext.GetHashCode()); currentBuildEventContextEvaluation.GetHashCode().ShouldNotBe(parentBuildEventContext.GetHashCode()); currentBuildEventContextProjectInstance.GetHashCode().ShouldNotBe(parentBuildEventContext.GetHashCode()); currentBuildEventProjectContext.GetHashCode().ShouldNotBe(parentBuildEventContext.GetHashCode()); currentBuildEventContextTarget.GetHashCode().ShouldNotBe(parentBuildEventContext.GetHashCode()); currentBuildEventContextTask.GetHashCode().ShouldNotBe(parentBuildEventContext.GetHashCode()); allDifferent.GetHashCode().ShouldNotBe(parentBuildEventContext.GetHashCode()); parentBuildEventContext.GetHashCode().ShouldBe(allSame.GetHashCode()); // submissison ID does not partake into equality currentBuildEventContextSubmission.ShouldBe(parentBuildEventContext); parentBuildEventContext.ShouldNotBe(currentBuildEventContext); parentBuildEventContext.ShouldNotBe(currentBuildEventContextNode); parentBuildEventContext.ShouldNotBe(currentBuildEventContextEvaluation); parentBuildEventContext.ShouldNotBe(currentBuildEventContextProjectInstance); parentBuildEventContext.ShouldNotBe(currentBuildEventProjectContext); parentBuildEventContext.ShouldNotBe(currentBuildEventContextTarget); parentBuildEventContext.ShouldNotBe(currentBuildEventContextTask); parentBuildEventContext.ShouldNotBe(allDifferent); parentBuildEventContext.ShouldBe(allSame); currentBuildEventContext.ShouldBe(currentBuildEventContext); parentBuildEventContext.ShouldNotBeNull(); currentBuildEventContext.ShouldNotBe(new object()); startedEvent.BuildEventContext.ShouldNotBeNull(); startedEvent.ParentProjectBuildEventContext.SubmissionId.ShouldBe(0); startedEvent.ParentProjectBuildEventContext.NodeId.ShouldBe(0); startedEvent.ParentProjectBuildEventContext.EvaluationId.ShouldBe(0); startedEvent.ParentProjectBuildEventContext.ProjectInstanceId.ShouldBe(0); startedEvent.ParentProjectBuildEventContext.ProjectContextId.ShouldBe(0); startedEvent.ParentProjectBuildEventContext.TargetId.ShouldBe(0); startedEvent.ParentProjectBuildEventContext.TaskId.ShouldBe(0); startedEvent.BuildEventContext.SubmissionId.ShouldBe(0); startedEvent.BuildEventContext.NodeId.ShouldBe(1); startedEvent.BuildEventContext.EvaluationId.ShouldBe(2); startedEvent.BuildEventContext.ProjectInstanceId.ShouldBe(3); startedEvent.BuildEventContext.ProjectContextId.ShouldBe(4); startedEvent.BuildEventContext.TargetId.ShouldBe(5); startedEvent.BuildEventContext.TaskId.ShouldBe(6); }