private void RunSimpleIntTest(Func <ISimpleInt, int, int, int> body, string result)
 {
     AssertException(() =>
     {
         var sut = new WrapperTest <ISimpleInt>(i => new LambdaWrapper(i, body));
         sut.AssertAllMethodsForward();
     }, result);
 }
        public void TestForwarding()
        {
            var tester = new WrapperTest <IFile>(target =>
            {
                var root = new Mock <IDirectory>();
                root.Setup(i => i.File("Test.txt")).Returns(target);
                return(new RelativeFile(() => root.Object, "Test.txt"));
            });

            tester.RegisterTypeCreator(() => new MemoryStream() as Stream);
            tester.AssertAllMethodsForward();
        }
        public void GetWorks()
        {
            var sut = new WrapperTest <IWithProperties>(target =>
            {
                var m = new Mock <IWithProperties>();
                m.SetupGet(i => i.Out).Returns(() => target.Out);
                m.SetupGet(i => i.InOut).Returns(() => target.InOut);
                m.SetupSet(i => i.InOut = It.IsAny <int>()).Callback((int v) => target.InOut = v);
                m.SetupSet(i => i.In    = It.IsAny <int>()).Callback((int v) => target.In = v);
                return(m.Object);
            });

            sut.AssertAllMethodsForward();
        }
Beispiel #4
0
        public void SwapableStorePostSwao()
        {
            var initialStore = CreateBackedStore();
            var tester       = new WrapperTest <ITransactableStore>(i =>
            {
                var swapable = new SwapableStore(initialStore.Object);
                AsyncPump.Run(() => swapable.CopyAndTransferToNewStore(i));
                return(swapable);
            });

            tester.RegisterTypeCreator(() => new MockDirectory("c:\\a") as IDirectory);
            tester.AssertAllMethodsForward();

            initialStore.VerifyGet(i => i.UntransactedRoot, Times.Once);
            initialStore.VerifyNoOtherCalls();
        }
Beispiel #5
0
        public void TestRelativeDirectory()
        {
            var tester = new WrapperTest <MVVM.FileSystem.IDirectory>(target =>
            {
                var root = new Mock <IDirectory>();
                root.Setup(i => i.SubDirectory("Test.txt")).Returns(target);
                return(new RelativeDirectory(() => root.Object, "Test.txt"));
            });

            tester.RegisterTypeCreator(() => new MemoryStream() as Stream);
            tester.ExcludeMember(i => i.File(""));
            tester.ExcludeMember(i => i.SubDirectory(""));
            tester.ExcludeMember(i => i.AllFiles());
            tester.ExcludeMember(i => i.AllFiles("*.*"));
            tester.ExcludeMember(i => i.AllSubDirectories());
            tester.AssertAllMethodsForward();
        }
        public void WorkingExample()
        {
            var sut = new WrapperTest <ISimpleInt>(i => new LambdaWrapper(i, (target, a, b) => target.Swap(a, b)));

            sut.AssertAllMethodsForward();
        }