public void Test_Round_Trip_Works_For_Normal_ViewModel_Requests()
        {
            ClearAll();

            var viewModelNameLookup = new MvxViewModelByNameLookup();
            viewModelNameLookup.AddAll(GetType().Assembly);
            Mvx.RegisterSingleton<IMvxViewModelByNameLookup>(viewModelNameLookup);

            var parameterBundle = new MvxBundle(new Dictionary<string, string> { { "On'e", "1'\\" }, { "Two", "2" } });
            var presentationBundle =
                new MvxBundle(new Dictionary<string, string> { { "Thre\"\'\\e", "3\"\'\\" }, { "Four", null } });
            var request = new MvxViewModelRequest<Test1ViewModel>(parameterBundle, presentationBundle,
                                                                  new MvxRequestedBy(
                                                                      MvxRequestedByType.AutomatedService, "HelloWorld"));

            var serializer = new MvxViewModelRequestCustomTextSerializer();
            var output = serializer.SerializeObject(request);

            var deserializer = new MvxViewModelRequestCustomTextSerializer();
            var deserialized = deserializer.DeserializeObject<MvxViewModelRequest>(output);

            Assert.AreEqual(typeof(Test1ViewModel), deserialized.ViewModelType);
            Assert.AreEqual(MvxRequestedByType.AutomatedService, deserialized.RequestedBy.Type);
            Assert.AreEqual("HelloWorld", deserialized.RequestedBy.AdditionalInfo);
            Assert.AreEqual(2, deserialized.PresentationValues.Count);
            Assert.AreEqual(2, deserialized.ParameterValues.Count);
            Assert.AreEqual("1'\\", deserialized.ParameterValues["On'e"]);
            Assert.AreEqual("2", deserialized.ParameterValues["Two"]);
            Assert.AreEqual("3\"\'\\", deserialized.PresentationValues["Thre\"\'\\e"]);
            Assert.AreEqual(null, deserialized.PresentationValues["Four"]);
        }
예제 #2
0
        public void Test_Round_Trip_Works_For_Normal_ViewModel_Requests()
        {
            _fixture.ClearAll();

            var viewModelNameLookup = new MvxViewModelByNameLookup();

            viewModelNameLookup.AddAll(GetType().Assembly);
            Mvx.RegisterSingleton <IMvxViewModelByNameLookup>(viewModelNameLookup);

            var parameterBundle = new MvxBundle(new Dictionary <string, string> {
                { "On'e", "1'\\" }, { "Two", "2" }
            });
            var presentationBundle =
                new MvxBundle(new Dictionary <string, string> {
                { "Thre\"\'\\e", "3\"\'\\" }, { "Four", null }
            });
            var request = new MvxViewModelRequest <Test1ViewModel>(parameterBundle, presentationBundle);

            var serializer = new MvxViewModelRequestCustomTextSerializer();
            var output     = serializer.SerializeObject(request);

            var deserializer = new MvxViewModelRequestCustomTextSerializer();
            var deserialized = deserializer.DeserializeObject <MvxViewModelRequest>(output);

            Assert.Equal(typeof(Test1ViewModel), deserialized.ViewModelType);
            Assert.Equal(2, deserialized.PresentationValues.Count);
            Assert.Equal(2, deserialized.ParameterValues.Count);
            Assert.Equal("1'\\", deserialized.ParameterValues["On'e"]);
            Assert.Equal("2", deserialized.ParameterValues["Two"]);
            Assert.Equal("3\"\'\\", deserialized.PresentationValues["Thre\"\'\\e"]);
            Assert.Null(deserialized.PresentationValues["Four"]);
        }
예제 #3
0
        public void Test_Round_Trip_Works_For_Part_Empty_ViewModel_Requests()
        {
            var parameterBundle    = new MvxBundle();
            var presentationBundle = new MvxBundle();
            var request            = new MvxViewModelRequest <Test1ViewModel>(parameterBundle, presentationBundle);

            var serializer = new MvxViewModelRequestCustomTextSerializer();
            var output     = serializer.SerializeObject(request);

            var deserializer = new MvxViewModelRequestCustomTextSerializer();
            var deserialized = deserializer.DeserializeObject <MvxViewModelRequest>(output);

            Assert.Equal(typeof(Test1ViewModel), deserialized.ViewModelType);
            Assert.Equal(0, deserialized.PresentationValues.Count);
            Assert.Equal(0, deserialized.ParameterValues.Count);
        }
        public void Test_Round_Trip_Works_For_Part_Empty_ViewModel_Requests()
        {
            var parameterBundle = new MvxBundle();
            var presentationBundle = new MvxBundle();
            var request = new MvxViewModelRequest<Test1ViewModel>(parameterBundle, presentationBundle,
                                                                  null);

            var serializer = new MvxViewModelRequestCustomTextSerializer();
            var output = serializer.SerializeObject(request);

            var deserializer = new MvxViewModelRequestCustomTextSerializer();
            var deserialized = deserializer.DeserializeObject<MvxViewModelRequest>(output);

            Assert.AreEqual(typeof(Test1ViewModel), deserialized.ViewModelType);
            Assert.AreEqual(MvxRequestedByType.Unknown, deserialized.RequestedBy.Type);
            Assert.AreEqual(null, deserialized.RequestedBy.AdditionalInfo);
            Assert.AreEqual(0, deserialized.PresentationValues.Count);
            Assert.AreEqual(0, deserialized.ParameterValues.Count);
        }