Пример #1
0
        public void WithViewData_On_PartialViewResult_Should_Throw_If_View_Data_Type_Does_Not_Match()
        {
            const string wrongViewDataType = "WrongType";
            var result = new PartialViewResult { ViewData = new ViewDataDictionary(wrongViewDataType) };

            result.WithViewData<CustomReferenceTypeViewData>();
        }
Пример #2
0
        public void WithViewData_On_PartialViewResult_Should_Throw_Exception_If_View_Data_Is_Null_And_Expected_Type_Is_Value_Type()
        {
            var renderResult = new PartialViewResult { ViewData = new ViewDataDictionary<CustomReferenceTypeViewData>() };

            renderResult.WithViewData<CustomValueTypeViewData>();
        }
Пример #3
0
        public void WithViewData_On_PartialViewResult_Should_Return_View_Data_If_View_Data_Type_Is_Implementation_Of_Generic_Interface()
        {
            var expectedData = new List<string> { "a", "b", "c" };
            var renderResult = new PartialViewResult { ViewData = new ViewDataDictionary(expectedData) };

            var result = renderResult.WithViewData<IList<string>>();

            Assert.That(result, Is.EqualTo(expectedData));
        }
Пример #4
0
        public void WithViewData_On_PartialViewResult_Should_Return_View_Data_If_View_Data_Type_Matches()
        {
            var expectedData = new CustomReferenceTypeViewData { ID = 2, Name = "Foo" };
            var renderResult = new PartialViewResult { ViewData = new ViewDataDictionary(expectedData) };

            var result = renderResult.WithViewData<CustomReferenceTypeViewData>();

            Assert.That(result, Is.EqualTo(expectedData));
        }
Пример #5
0
        public void WithViewData_On_PartialViewResult_Should_Return_Null_If_View_Data_Is_Null_And_Expected_Type_Is_Reference_Type()
        {
            var renderResult = new PartialViewResult { ViewData = new ViewDataDictionary<CustomReferenceTypeViewData>() };

            var result = renderResult.WithViewData<CustomReferenceTypeViewData>();

            Assert.That(result, Is.Null);
        }