Ejemplo n.º 1
0
        public void SaveTempDataFilter_OnResultExecuted_DoesNotKeepTempData_ForNonIKeepTempDataResult()
        {
            // Arrange
            var tempData = new Mock<ITempDataDictionary>(MockBehavior.Strict);
            var filter = new SaveTempDataFilter(tempData.Object);

            var context = new ResultExecutedContext(
                new ActionContext(),
                new IFilterMetadata[] { },
                new Mock<IActionResult>().Object,
                new object());

            // Act 
            filter.OnResultExecuted(context);

            // Assert - The mock will throw if we do the wrong thing.
        }
Ejemplo n.º 2
0
        public void SaveTempDataFilter_OnResultExecuted_DoesNotKeepTempData_ForNonIKeepTempDataResult()
        {
            // Arrange
            var tempData = new Mock <ITempDataDictionary>(MockBehavior.Strict);
            var filter   = new SaveTempDataFilter(tempData.Object);

            var context = new ResultExecutedContext(
                new ActionContext(),
                new IFilterMetadata[] { },
                new Mock <IActionResult>().Object,
                new object());

            // Act
            filter.OnResultExecuted(context);

            // Assert - The mock will throw if we do the wrong thing.
        }
Ejemplo n.º 3
0
        public void SaveTempDataFilter_OnResultExecuted_KeepsTempData_ForIKeepTempDataResult()
        {
            // Arrange
            var tempData = new Mock<ITempDataDictionary>(MockBehavior.Strict);
            tempData
                .Setup(m => m.Keep())
                .Verifiable();

            var filter = new SaveTempDataFilter(tempData.Object);

            var context = new ResultExecutedContext(
                new ActionContext(),
                new IFilterMetadata[] { },
                new Mock<IKeepTempDataResult>().Object,
                new object());

            // Act
            filter.OnResultExecuted(context);

            // Assert
            tempData.Verify();
        }
Ejemplo n.º 4
0
        public void SaveTempDataFilter_OnResultExecuted_KeepsTempData_ForIKeepTempDataResult()
        {
            // Arrange
            var tempData = new Mock <ITempDataDictionary>(MockBehavior.Strict);

            tempData
            .Setup(m => m.Keep())
            .Verifiable();

            var filter = new SaveTempDataFilter(tempData.Object);

            var context = new ResultExecutedContext(
                new ActionContext(),
                new IFilterMetadata[] { },
                new Mock <IKeepTempDataResult>().Object,
                new object());

            // Act
            filter.OnResultExecuted(context);

            // Assert
            tempData.Verify();
        }