public void Test_NoReloadState()
        {
            ClearAll();

            Ioc.RegisterSingleton<IMvxStringToTypeParser>(new MvxStringToTypeParser());

            var testThing = new MockTestThing();
            Ioc.RegisterSingleton<ITestThing>(testThing);

            var testObject = new BundleObject
            {
                TheBool1 = false,
                TheBool2 = true,
                TheGuid1 = Guid.NewGuid(),
                TheGuid2 = new Guid(123, 10, 444, 1, 2, 3, 4, 5, 6, 7, 8),
                TheInt1 = 123,
                TheInt2 = 456,
                TheString1 = "Hello World",
                TheString2 = null
            };
            var bundle = new MvxBundle();
            bundle.Write(testObject);

            var toTest = new MvxDefaultViewModelLocator();

            IMvxViewModel viewModel = toTest.Load(typeof(Test1ViewModel), bundle, null);

            Assert.IsNotNull(viewModel);
            var typedViewModel = (Test1ViewModel)viewModel;
            Assert.AreSame(bundle, typedViewModel.BundleInit);
            Assert.IsNull(typedViewModel.BundleState);
            Assert.AreSame(testThing, typedViewModel.Thing);
            Assert.AreEqual(testObject, typedViewModel.TheInitBundleSet);
            Assert.IsNull(typedViewModel.TheReloadBundleSet);
            Assert.AreEqual(testObject.TheGuid1, typedViewModel.TheInitGuid1Set);
            Assert.AreEqual(testObject.TheGuid2, typedViewModel.TheInitGuid2Set);
            Assert.AreEqual(testObject.TheString1, typedViewModel.TheInitString1Set);
            Assert.AreEqual(Guid.Empty, typedViewModel.TheReloadGuid1Set);
            Assert.AreEqual(Guid.Empty, typedViewModel.TheReloadGuid2Set);
            Assert.AreEqual(null, typedViewModel.TheReloadString1Set);
            Assert.IsTrue(typedViewModel.StartCalled);
        }
Esempio n. 2
0
        public void Test_FillArguments()
        {
            ClearAll();

            Ioc.RegisterSingleton<IMvxStringToTypeParser>(new MvxStringToTypeParser());

            var testObject = new BundleObject
            {
                TheBool1 = false,
                TheBool2 = true,
                TheGuid1 = Guid.NewGuid(),
                TheGuid2 = new Guid(123, 10, 444, 1, 2, 3, 4, 5, 6, 7, 8),
                TheInt1 = 123,
                TheInt2 = 456,
                TheString1 = "Hello World",
                TheString2 = "Goo"
            };
            var bundle = new MvxBundle();
            bundle.Write(testObject);

            var method = this.GetType().GetMethod("TestFunction");
            var args = bundle.CreateArgumentList(method.GetParameters(), "ignored debug text");
            var output = method.Invoke(this, args.ToArray());

            var expected = new BundleObject
            {
                TheBool1 = false,
                TheBool2 = true,
                TheGuid1 = Guid.Empty,
                TheGuid2 = new Guid(123, 10, 444, 1, 2, 3, 4, 5, 6, 7, 8),
                TheInt1 = 0,
                TheInt2 = 456,
                TheString1 = "Hello World",
                TheString2 = null
            };
            Assert.AreEqual(expected, output);
        }
Esempio n. 3
0
        public void Test_RoundTrip()
        {
            ClearAll();

            Ioc.RegisterSingleton<IMvxStringToTypeParser>(new MvxStringToTypeParser());

            var testObject = new BundleObject
            {
                TheBool1 = false,
                TheBool2 = true,
                TheGuid1 = Guid.NewGuid(),
                TheGuid2 = new Guid(123, 10, 444, 1, 2, 3, 4, 5, 6, 7, 8),
                TheInt1 = 123,
                TheInt2 = 456,
                TheString1 = "Hello World",
                TheString2 = null
            };
            var bundle = new MvxBundle();
            bundle.Write(testObject);

            var output = bundle.Read<BundleObject>();

            Assert.AreEqual(testObject, output);
        }
Esempio n. 4
0
 public void ReloadState(BundleObject bundle)
 {
     this.TheReloadBundleSet = bundle;
 }
Esempio n. 5
0
 public void Init(BundleObject bundle)
 {
     this.TheInitBundleSet = bundle;
 }
Esempio n. 6
0
 public void ReloadState(BundleObject bundle)
 {
     TheReloadBundleSet = bundle;
 }
Esempio n. 7
0
 public void Init(BundleObject bundle)
 {
     TheInitBundleSet = bundle;
 }