Example #1
0
        public static void AutoBodyBy(MockStorage ms)
        {
            var proc = new PProxyProcess();

            proc.AutoBodyBy(ms);

            ms.Customize(c => c.Do(PProcess.GetCurrentProcess).Setup(_ => _()).Returns(proc)).
            Customize(c => c.Do(PProcess.StartProcessStartInfo).Setup(_ => _(It.IsAny <ProcessStartInfo>())).Returns(proc));
        }
Example #2
0
        public static void AutoBodyBy(this PProxyProcess proc, MockStorage ms)
        {
            var procMod = new PProxyProcessModule();

            procMod.AutoBodyBy(ms);

            ms.Customize(c => c.Do(proc.StartInfoGet).Setup(_ => _(It.IsAny <Process>())).Returns(new ProcessStartInfo())).
            Customize(c => c.Do(proc.MainModuleGet).Setup(_ => _(It.IsAny <Process>())).Returns(procMod)).
            Customize(c => c.Do(proc.CloseMainWindow).Setup(_ => _(It.IsAny <Process>())).Returns(true));
        }
Example #3
0
        public void MockStorage_should_provide_fluent_setup_through_itself()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var ms = new MockStorage(MockBehavior.Strict);
                PProcessMixin.AutoBodyBy(ms);
                ms.Customize(c => c.
                             Do(PProcess.StartProcessStartInfo).Expect(_ => _(It.Is <ProcessStartInfo>(x =>
                                                                                                       x.Arguments == "\"arg ument1\" \"argume nt2\""
                                                                                                       ))).Returns(new PProxyProcess())
                             );

                // Act
                var proc = Process.Start(new ProcessStartInfo(Guid.NewGuid().ToString(), "\"arg ument1\" \"argume nt2\""));

                // Assert
                Assert.IsNotNull(proc);
                ms.Verify();
            }
        }
Example #4
0
 public static void AutoBodyBy(this PProxyProcessModule procMod, MockStorage ms)
 {
     procMod.ModuleNameGet().Body = @this => Guid.NewGuid().ToString(); // to avoid NullReferenceException that is caused in Moq.
     ms.Customize(c => c.Do(procMod.FileNameGet).Setup(_ => _(It.IsAny <ProcessModule>())).Returns(Guid.NewGuid().ToString()));
 }