コード例 #1
0
        public void To_should_return_builder_from_factory()
        {
            // Arrange
            var foo  = A.Fake <IFoo>();
            var fake = Fake.GetFakeObject(foo);

            var recordedRule = A.Fake <RecordedCallRule>();

            this.StubResolve <RecordedCallRule.Factory>(() => recordedRule);

            var recordingRule        = A.Fake <RecordingCallRule <IFoo> >(() => new RecordingCallRule <IFoo>(fake, recordedRule, x => null));
            var recordingRuleFactory = A.Fake <IRecordingCallRuleFactory>();

            A.CallTo(() => recordingRuleFactory.Create <IFoo>(fake, recordedRule)).Returns(recordingRule);
            this.StubResolve <IRecordingCallRuleFactory>(recordingRuleFactory);

            var builder = new RuleBuilder(A.Fake <BuildableCallRule>(), fake, x => null);

            this.StubResolve <RuleBuilder.Factory>((r, f) =>
            {
                return(r.Equals(recordedRule) && f.Equals(fake) ? builder : null);
            });

            // Act
            var result = ThisCall.To(foo);

            // Assert
            Assert.That(result, Is.SameAs(builder));
            Assert.That(fake.Rules, Has.Some.SameAs(recordingRule));
        }
コード例 #2
0
        public void Recorded_call_should_not_be_applied_when_arguments_are_not_the_same_as_used_when_recording()
        {
            var fake = A.Fake <IFoo>();

            ThisCall.To(fake).Throws(new AssertionException("This should not be thrown!"));
            fake.Baz(1, 2);

            Assert.That(fake.Baz("foo", "bar"), Is.Not.EqualTo(10));
        }
コード例 #3
0
        public void Recorded_call_should_not_be_applied_when_arguments_does_not_match_specified_argument_predicate()
        {
            var fake = A.Fake <IFoo>();

            ThisCall.To(fake).WhenArgumentsMatch(x => false).Throws(new AssertionException("This should not happen"));
            fake.Bar(10);

            fake.Bar(10);
        }
コード例 #4
0
        public void Recorded_calls_should_only_be_applicable_to_the_method_called()
        {
            var fake = A.Fake <IFoo>();

            ThisCall.To(fake).Throws(new Exception("This should not be thrown!"));
            fake.Bar();

            fake.Baz();
        }
コード例 #5
0
        public void With_any_arguments_should_configure_call_so_that_any_arguments_matches()
        {
            var fake = A.Fake <IFoo>();

            ThisCall.To(fake).WithAnyArguments().Throws(new ApplicationException());
            fake.Baz(null, null);

            Assert.Throws <ApplicationException>(() =>
                                                 fake.Baz("foo", "bar"));
        }
コード例 #6
0
        public void Throws_should_throw_exception_when_configured_method_is_called_but_not_while_recording()
        {
            var fake = A.Fake <IFoo>();

            ThisCall.To(fake).Throws(new ApplicationException());
            fake.Bar();

            Assert.Throws <ApplicationException>(() =>
                                                 fake.Bar());
        }
コード例 #7
0
        public void Recorded_call_should_apply_when_argument_predicate_returns_true()
        {
            var fake = A.Fake <IFoo>();

            ThisCall.To(fake).WhenArgumentsMatch(x => true).Throws(new ArgumentNullException());
            fake.Bar(10);

            Assert.Throws <ArgumentNullException>(() =>
                                                  fake.Bar(10));
        }
コード例 #8
0
        public void Recording_a_rule_should_work_even_when_there_are_already_call_rules_specified()
        {
            var fake = A.Fake <IFoo>();

            Configure.Fake(fake).CallsTo(x => x.Baz()).Returns(10);
            Configure.Fake(fake).CallsTo(x => x.Biz()).Returns("something");

            ThisCall.To(fake).Throws(new ApplicationException());
            fake.Bar();

            Assert.Throws <ApplicationException>(() =>
                                                 fake.Bar());
        }
コード例 #9
0
        public void Arguments_from_the_call_should_be_sent_to_the_argument_predicate()
        {
            var fake = A.Fake <IFoo>();
            ArgumentCollection arguments = null;

            ThisCall.To(fake).WhenArgumentsMatch(x => { arguments = x; return(true); }).Throws(new ApplicationException());
            fake.Baz(null, null);

            try
            {
                fake.Baz(1, "a");
            }
            catch (ApplicationException) { }

            Assert.That(arguments.AsEnumerable().ToArray(), Has.Some.EqualTo(1).And.Some.EqualTo("a"));
        }
コード例 #10
0
 public static void CTriggerWar3__ExecutePrototype(CTriggerWar3Ptr @this, IntPtr a2)
 {
     ThisCall.Invoke <IntPtr>(GameAddresses.CTriggerWar3__Execute, @this, a2);
 }
コード例 #11
0
        //public static AbilDataCacheNodePtr GetAbilDataCacheNodeFromId(ObjectIdL id)
        //{
        //    return FastCall.Invoke<AbilDataCacheNodePtr>(GameAddresses.GetAbilDataCacheNodeFromId, (object)id);
        //}

        //public static IntPtr CGameUI__Constructor(CGameUI @this)
        //{
        //    return ThisCall.Invoke<IntPtr>(GameAddresses.CGameUI__Constructor, (object)@this);
        //}

        //public static unsafe IntPtr CGameUI__DisplayChatMessage(CGameUI* @this, int sender, string message, ChatRecipients recipients, float duration)
        //{
        //    return ThisCall.Invoke<IntPtr>(GameAddresses.CGameUI__DisplayChatMessage, (IntPtr)((void*)@this), sender, message, recipients, duration);
        //}

        //public static bool Unknown__UpdateMouse(IntPtr @this, float uiX, float uiY, IntPtr terrainPtr, IntPtr a4)
        //{
        //    return ThisCall.Invoke<bool>(GameAddresses.Unknown__UpdateMouse, @this, uiX, uiY, terrainPtr, a4);
        //}

        public static int Unknown__SetState(IntPtr @this, bool endMap, bool endEngine)
        {
            return(ThisCall.Invoke <int>(GameAddresses.Unknown__SetState, @this, endMap, endEngine));
        }
コード例 #12
0
 // Constructor: 0074F0 found using "e:\\drive1\\temp\\buildwar3x\\war3\\source\\Data.h", 3rd result, constructor style function.
 // Data, size = 0x408
 public static Int32 Unknown__SetState(IntPtr @this, Boolean endMap, Boolean endEngine)
 {
     return(ThisCall.Invoke <Int32>(GameAddresses.Unknown__SetState, @this, endMap, endEngine));
 }
コード例 #13
0
 /// <summary>
 /// Displays a chat message as sent by a player.
 /// </summary>
 /// <param name="this">The CGameUI instance.</param>
 /// <param name="sender">The player that send the message.</param>
 /// <param name="message">The message sent.</param>
 /// <param name="recipients">The team to receive the message.</param>
 /// <param name="duration">The duration the message should be shown.</param>
 /// <returns>Unknown</returns>
 public static IntPtr CGameUI__DisplayChatMessage(CGameUI @this, Int32 sender, String message, ChatRecipients recipients, Single duration)
 {
     return(ThisCall.Invoke <IntPtr>(GameAddresses.CGameUI__DisplayChatMessage, @this, sender, message, recipients, duration));
 }
コード例 #14
0
 /// <summary>
 /// Prints a message.
 /// </summary>
 /// <param name="_this">The CSimpleMessageFrame to print the message.</param>
 /// <param name="message">The message.</param>
 /// <param name="color">The base color.</param>
 /// <param name="duration">The duration.</param>
 /// <param name="a5">Unknown</param>
 /// <returns>Unknown</returns>
 public static IntPtr CSimpleMessageFrame__WriteLine(CSimpleMessageFramePtr @this, String message, ref Color color, Single duration, Int32 a5)
 {
     fixed(Color *colorPtr = &color)
     return(ThisCall.Invoke <IntPtr>(GameAddresses.CSimpleMessageFrame__WriteLine, @this, message, new IntPtr(colorPtr), duration, a5));
 }
コード例 #15
0
 public static CodeResult VirtualMachine__RunCode(VirtualMachinePtr @this, IntPtr opCode, IntPtr a3, UInt32 opLimit, IntPtr a5)
 {
     return(ThisCall.Invoke <CodeResult>(GameAddresses.VirtualMachine__RunCode, @this, opCode, a3, opLimit, a5));
 }
コード例 #16
0
 public void To_should_be_properly_guarded()
 {
     IsProperlyGuardedConstraint.IsProperlyGuarded(() => ThisCall.To(A.Fake <IFoo>()));
 }
コード例 #17
0
 public static unsafe IntPtr CGameUI__DisplayChatMessage(CGameUI * @this, int sender, string message, ChatRecipients recipients, float duration)
 {
     return(ThisCall.Invoke <IntPtr>(GameAddresses.CGameUI__DisplayChatMessage, (IntPtr)(void *)@this, sender, message, recipients, duration));
 }
コード例 #18
0
 public static bool Unknown__UpdateMouse(IntPtr @this, float uiX, float uiY, IntPtr terrainPtr, IntPtr a4)
 {
     return(ThisCall.Invoke <bool>(GameAddresses.Unknown__UpdateMouse, @this, uiX, uiY, terrainPtr, a4));
 }
コード例 #19
0
 public void To_should_be_properly_guarded()
 {
     NullGuardedConstraint.Assert(() => ThisCall.To(A.Fake <IFoo>()));
 }
コード例 #20
0
 public static IntPtr JassStringManager__ResizePrototype(JassStringManager * @this, UInt32 newSize)
 {
     return(ThisCall.Invoke <IntPtr>(GameAddresses.JassStringManager__Resize, new IntPtr(@this), newSize));
 }
コード例 #21
0
 public static JassPtr Jass__Constructor(JassPtr @this)
 {
     return(ThisCall.Invoke <JassPtr>(GameAddresses.Jass__Constructor, @this));
 }
コード例 #22
0
ファイル: CAgentInternal.cs プロジェクト: OMGhhh/OpenCirnix
 public unsafe ObjectIdL GetClassId()
 {
     return(ThisCall.Invoke <ObjectIdL>(Virtual->CAgent__GetClassId, (object)AsSafe()));
 }
コード例 #23
0
 public static IntPtr VirtualMachine__RunFunction(VirtualMachinePtr @this, String functionName, IntPtr a3, IntPtr a4, IntPtr a5, IntPtr a6)
 {
     return(ThisCall.Invoke <IntPtr>(GameAddresses.VirtualMachine__RunFunction, @this, functionName, a3, a4, a5, a6));
 }
コード例 #24
0
 public CAbility *GetAbility(ObjectIdL ability)
 {
     return(ThisCall.Invoke <CAbilityPtr>(GameAddresses.CUnit__GetAbility, ability, false, true, true, true).AsUnsafe());
 }
コード例 #25
0
 public static IntPtr CGameUI__Constructor(CGameUI @this)
 {
     return(ThisCall.Invoke <IntPtr>(GameAddresses.CGameUI__Constructor, @this));
 }
コード例 #26
0
 public static unsafe CodeResult VirtualMachine__RunCode(VirtualMachine * @this, IntPtr opCode, IntPtr a3, uint opLimit, IntPtr a5)
 {
     return(ThisCall.Invoke <CodeResult>(GameAddresses.VirtualMachine__RunCode, new IntPtr((void *)@this), opCode, a3, opLimit, a5));
 }
コード例 #27
0
 // Constructor: 39A910 found using ".\CWorldFrameWar3.cpp", used three times in one function, initializer style function.
 // CWorldFrameWar3, size = 0x668
 public static Boolean Unknown__UpdateMouse(IntPtr @this, Single uiX, Single uiY, IntPtr terrainPtr, IntPtr a4)
 {
     return(ThisCall.Invoke <Boolean>(GameAddresses.Unknown__UpdateMouse, @this, uiX, uiY, terrainPtr, a4));
 }
コード例 #28
0
 public static unsafe IntPtr VirtualMachine__RunFunction(VirtualMachine * @this, string functionName, IntPtr a3, IntPtr a4, IntPtr a5, IntPtr a6)
 {
     return(ThisCall.Invoke <IntPtr>(GameAddresses.VirtualMachine__RunFunction, new IntPtr((void *)@this), functionName, a3, a4, a5, a6));
 }
コード例 #29
0
ファイル: CAgentInternal.cs プロジェクト: OMGhhh/OpenCirnix
 public unsafe string GetClassName()
 {
     return(Memory.ReadString(ThisCall.Invoke <IntPtr>(Virtual->CAgent__GetClassName, (object)AsSafe())));
 }
コード例 #30
0
 public static unsafe IntPtr JassStringManager__ResizePrototype(JassStringManager * @this, uint newSize)
 {
     return(ThisCall.Invoke <IntPtr>(GameAddresses.JassStringManager__Resize, new IntPtr((void *)@this), newSize));
 }