Ejemplo n.º 1
0
        public void GetRegisteredTasksOfDefault()
        {
            var expected = new DefaultTaskContext().TaskService.GetRegisteredTasks();
            var actual   = TaskContext.Default.TaskService.GetRegisteredTasks();

            Assert.AreElementsSame(expected, actual);
        }
Ejemplo n.º 2
0
        public void PropertyGeneralNormalBehavior()
        {
            // Test read access of 'General' Property.
            var expected  = testObject["General"].Keys;
            var actual    = testObject.General.Keys;
            var expectedV = testObject["General"].Values;
            var actualV   = testObject.General.Values;

            Assert.AreElementsSame(expected, actual);
            Assert.AreElementsSame(expectedV, actualV);

            // Moo.FirstOne -> item1; General.InGeneral -> item1; NotInGeneral.X-Key -> item2; General.ReallyCool -> item3
            // [1+G2] item1 = { Enabled = true };
            // [   3] item2 = { Id = new Guid("2764B5BE-6E56-4694-B1A1-5C105420CB7F") };
            // [  G4] item3 = { Enabled = true, Id = new Guid("0AE4E28A-9B78-43bf-ABD2-9F7CB5F3833B") };
            AddDefaultTestItems();

            Assert.AreEqual(2, testObject.General.Count);
            expected  = testObject["General"].Keys;
            actual    = testObject.General.Keys;
            expectedV = testObject["General"].Values;
            actualV   = testObject.General.Values;
            Assert.AreElementsSame(expected, actual);
            Assert.AreElementsSame(expectedV, actualV);
        }
Ejemplo n.º 3
0
        public void Constructs_ok()
        {
            var attribute1  = new NodeAttribute(123, "name1", "value1", 999);
            var attribute2  = new NodeAttribute(456, "name2", "value2", 999);
            var declaration = new NodeDeclaration(new[] { attribute1, attribute2 });

            Assert.AreElementsSame(new[] { attribute1, attribute2 }, declaration.Attributes);
        }
Ejemplo n.º 4
0
        public void AreElementsSame_fails_with_custom_message()
        {
            var o1 = new object();
            var o2 = new object();

            AssertionFailure[] failures = Capture(() => Assert.AreElementsSame(new[] { o1 }, new[] { o2 }, "{0} message", "custom"));
            Assert.Count(1, failures);
            Assert.AreEqual("custom message", failures[0].Message);
        }
Ejemplo n.º 5
0
        public void AreElementsSame_with_different_types()
        {
            var o1 = new object();
            var o2 = new object();

            Assert.AreElementsSame(new[] { o1, o2 }, new List <object> {
                o1, o2
            });
        }
Ejemplo n.º 6
0
        public void ConstructsOk()
        {
            var object1 = new object();
            var object2 = new object();
            var object3 = new object();
            var target  = new EquivalenceClass(object1, object2, object3);

            Assert.AreElementsSame(new[] { object1, object2, object3 }, target.Cast <object>());
        }
Ejemplo n.º 7
0
        public void Constructs_ok()
        {
            var mockPath = MockRepository.GenerateStub <IXmlPathStrict>();
            var diff1    = new Diff(DiffType.MissingAttribute, mockPath, DiffTargets.Actual);
            var diff2    = new Diff(DiffType.MissingAttribute, mockPath, DiffTargets.Actual);
            var diff3    = new Diff(DiffType.MissingAttribute, mockPath, DiffTargets.Actual);
            var diffSet  = new DiffSet(new[] { diff1, diff2, diff3 });

            Assert.IsFalse(diffSet.IsEmpty);
            Assert.AreElementsSame(new[] { diff1, diff2, diff3 }, diffSet);
        }
        public void Constructs_ok()
        {
            var attribute1 = new Gallio.Common.Xml.NodeAttribute(123, "name1", "value1", 999);
            var attribute2 = new Gallio.Common.Xml.NodeAttribute(456, "name2", "value2", 999);
            var attribute3 = new Gallio.Common.Xml.NodeAttribute(789, "name3", "value3", 999);
            var array      = new[] { attribute1, attribute2, attribute3 };
            var collection = new NodeAttributeCollection(array);

            Assert.Count(3, collection);
            Assert.AreElementsSame(array, collection);
        }
Ejemplo n.º 9
0
        public void Constructs_ok()
        {
            var mockMarkup1 = MockRepository.GenerateStub <INode>();
            var mockMarkup2 = MockRepository.GenerateStub <INode>();
            var mockMarkup3 = MockRepository.GenerateStub <INode>();
            var array       = new[] { mockMarkup1, mockMarkup2, mockMarkup3 };
            var collection  = new NodeCollection(array);

            Assert.Count(3, collection);
            Assert.AreElementsSame(array, collection);
        }
Ejemplo n.º 10
0
        public void AreElementsSame_fails_when_elements_are_in_different_order()
        {
            var o1 = new object();
            var o2 = new object();

            AssertionFailure[] failures = Capture(()
                                                  => Assert.AreElementsSame(new[] { o1, o2 }, new List <object> {
                o2, o1
            }));
            Assert.Count(1, failures);
            Assert.AreEqual("Expected elements to be referentially equal but they differ in at least one position.", failures[0].Description);
        }
Ejemplo n.º 11
0
        public void TestDecompilationResultHasCorrectParameters(IManagedMethod method)
        {
            var decompiled     = Decompile(method);
            var parameterTypes = method.GetParameters().Select(p => p.ParameterType).ToList();

            if (!method.IsStatic)
            {
                parameterTypes.Insert(0, method.DeclaringType);
            }

            Assert.AreElementsSame(parameterTypes, decompiled.Parameters.Select(p => p.Type));
        }
Ejemplo n.º 12
0
        public void Constructs_non_empty_element()
        {
            var attribute1 = new Gallio.Common.Xml.NodeAttribute(0, "diameter", "4878 km", 2);
            var attribute2 = new Gallio.Common.Xml.NodeAttribute(1, "revolution", "58.6 d", 2);
            var mockChild1 = MockRepository.GenerateStub <INode>();
            var mockChild2 = MockRepository.GenerateStub <INode>();
            var element    = new NodeElement(0, 123, "Planet", new[] { attribute1, attribute2 }, new[] { mockChild1, mockChild2 });

            Assert.AreElementsSame(new[] { mockChild1, mockChild2 }, element.Children);
            Assert.AreElementsSame(new[] { attribute1, attribute2 }, element.Attributes);
            Assert.AreEqual("Planet", element.Name);
        }
Ejemplo n.º 13
0
        public void DeserializeAllSetupDataWithPropertyBuilder()
        {
            // <NStub.CSharp.ObjectGeneration.Builders.DefaultMethodEraser><EmptyBuildParameters>
            var xml = TestDataProvider.BuildParametersMinimalDefaultMethodEraserXml();

            Expect.Call(handler.Type).Return(typeof(DefaultMethodEraser)).Repeat.Any();
            Expect.Call(handler.IsMultiBuilder).Return(false).Repeat.Any();
            Expect.Call(handler.ParameterDataType).Return(typeof(string)).Repeat.Any();
            mocks.ReplayAll();
            var result = testObject.DeserializeAllSetupData(xml, properties, new[] { handler });

            Assert.AreElementsSame(new[] { new EmptyBuildParameters() }, result);
            mocks.VerifyAll();
        }
        public void ShouldRaiseEventsInCorrectOrder()
        {
            var callstack = new List <string>();
            var foo       = new Foo();

            foo.PropertyChanging += (sender, e) => callstack.Add("Changing");
            foo.PropertyChanged  += (sender, e) => callstack.Add("Changed");

            NotifiableProperty.Set(foo, x => x.Name, "new name");

            Assert.AreElementsSame(
                new[] { "Changing", "Changed" },
                callstack
                );
        }
Ejemplo n.º 15
0
        public void AreElementsSame_with_objects()
        {
            var o = new object();

            Assert.AreElementsSame(new[] { o }, new[] { o });
        }