Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public void Compare()
        {
            Assert.IsTrue(BuildEventContext.Invalid == BuildEventContext.Invalid, "#1");
            Assert.IsFalse(BuildEventContext.Invalid != BuildEventContext.Invalid, "#2");
            var inst = new BuildEventContext(0, 0, 0, 0);

            Assert.IsFalse(BuildEventContext.Invalid == inst, "#3");
            Assert.IsTrue(BuildEventContext.Invalid != inst, "#4");
            Assert.IsFalse(BuildEventContext.Invalid == null, "#5");
            Assert.IsTrue(BuildEventContext.Invalid != null, "#6");
            Assert.IsFalse(BuildEventContext.Invalid.Equals(null), "#7");
            Assert.IsFalse(BuildEventContext.Invalid.Equals(inst), "#8");
            Assert.IsTrue(BuildEventContext.Invalid.Equals(BuildEventContext.Invalid), "#9");
            Assert.IsFalse(inst.Equals(null), "#10");
            Assert.IsTrue(inst.Equals(inst), "#11");
            Assert.IsFalse(inst.Equals(BuildEventContext.Invalid), "#12");
        }