示例#1
0
        public void RemoveForwardsToNextStep()
        {
            var vg = new VerificationGroup();

            EventStep.ExpectedUsage(vg, null, expectedNumberOfAdds: 0, expectedNumberOfRemoves: 1);

            EventStep.Remove(MockInfo.Lenient, _eventHandler);

            vg.Assert();
        }
        public void SetForwardsToNextStep()
        {
            var vg = new VerificationGroup();

            PropertyStep.ExpectedUsage(vg, null, expectedNumberOfGets: 0, expectedNumberOfSets: 1);

            PropertyStep.Set(MockInfo.Lenient, 1);

            vg.Assert();
        }
        public void CallForwardsToNextStep()
        {
            var vg = new VerificationGroup();

            MethodStep.ExpectedUsage(vg, null, expectedNumberOfCalls: 1);

            MethodStep.Call(MockInfo.Lenient, 1);

            vg.Assert();
        }
示例#4
0
        public void UseElseBranchIfAskedInNoParameterCase()
        {
            var vg = new VerificationGroup();

            MockMembers.SimpleFunc
            .InstanceIf(inst => true, s => s.ExpectedUsage(vg, "IfBranch", 1).Join(s.ElseBranch))
            .ExpectedUsage(vg, "ElseBranch", 1);

            Sut.SimpleFunc();

            vg.Assert();
        }
示例#5
0
        public void UseElseBranchIfAsked()
        {
            var vg = new VerificationGroup();

            MockMembers.FuncWithParameter
            .InstanceIf((inst, i) => true, s => s.ExpectedUsage(vg, "IfBranch", 1).Join(s.ElseBranch))
            .ExpectedUsage(vg, "ElseBranch", 1);

            Sut.FuncWithParameter(42);

            vg.Assert();
        }
示例#6
0
        public void CallBaseIfConditionsAreNotMet()
        {
            var group = new VerificationGroup();

            MockMembers.SimpleAction
            .InstanceIf(i => false, b => b.ExpectedUsage(group, null, 0))
            .ExpectedUsage(group, null, 1);

            Sut.SimpleAction();

            group.Assert();
        }
示例#7
0
        public void CallBaseIfConditionsAreNotMet()
        {
            var group = new VerificationGroup();

            MockMembers.MyEvent
            .InstanceIf((i, h) => false, (i, h) => false, b => b.ExpectedUsage(group, null, 0, 0))
            .ExpectedUsage(group, null, 1, 1);

            Sut.MyEvent += MyFirstEventHandler;
            Sut.MyEvent -= MyFirstEventHandler;

            group.Assert();
        }
示例#8
0
        public void UseElseBranchIfAsked()
        {
            var vg = new VerificationGroup();

            MockMembers.StringProperty
            .If(() => true, v => true, s => s.ExpectedUsage(vg, "IfBranch", 1, 1).Join(s.ElseBranch))
            .ExpectedUsage(vg, "ElseBranch", 1, 1);

            Sut.StringProperty = "one";
            var _ = Sut.StringProperty;

            vg.Assert();
        }
示例#9
0
        public void CheckConditionInNoReturnValueCase()
        {
            var group = new VerificationGroup();

            MockMembers.ActionWithParameter
            .If(a => a > 5, s => s.ExpectedUsage(group, null, 1))
            .ExpectedUsage(group, null, 2);

            Sut.ActionWithParameter(1);
            Sut.ActionWithParameter(6);
            Sut.ActionWithParameter(-3);

            group.Assert();
        }
示例#10
0
        public void CheckConditionInNoParameterOrReturnValueCase()
        {
            bool flag = false;

            var group = new VerificationGroup();

            MockMembers.SimpleAction
            // ReSharper disable once AccessToModifiedClosure
            .If(() => flag, s => s.ExpectedUsage(group, null, 1))
            .ExpectedUsage(group, null, 2);

            Sut.SimpleAction();
            Sut.SimpleAction();
            flag = true;
            Sut.SimpleAction();

            group.Assert();
        }