Ejemplo n.º 1
0
        public async Task ReturnCorrectRedirectToActionResult_UsingDelete()
        {
            await Task.Run(async() =>
            {
                // Arrange
                using (var controller = new MockedWeightLiftingSetController())
                {
                    // Act
                    var iActionResult = await controller.AuthenticatedInstance.Delete(1, 1);

                    // Assert
                    var actualViewResultModel = JsonConvert.SerializeObject(iActionResult, new JsonSerializerSettings()
                    {
                        Formatting = Formatting.Indented
                    }).MinifyJson().PrettifyJson();
                    var expectedViewResultModel =
                        @"
                            {
                              ""UrlHelper"": null,
                              ""ActionName"": ""HistoryDetails"",
                              ""ControllerName"": ""WorkoutHistory"",
                              ""RouteValues"": {
                                ""workoutHistoryId"": 1
                              },
                              ""Permanent"": false,
                              ""PreserveMethod"": false,
                              ""Fragment"": null
                            }
                        ".MinifyJson().PrettifyJson();

                    Assert.AreEqual(expectedViewResultModel, actualViewResultModel);
                }
            });
        }
Ejemplo n.º 2
0
        public async Task ReturnRedirectToAccessDenied_WhenUnauthorized_UsingCreateNewWeightLiftingSet()
        {
            await Task.Run(async() =>
            {
                using (var controller = new MockedWeightLiftingSetController())
                {
                    // Act
                    var iActionResult = await controller.UnAuthenticatedInstance.CreateNewWeightLiftingSet(new WeightLiftingSetOfmForPost()
                    {
                        ExerciseHistoryId = 5
                    }, workoutHistoryId: 1);

                    var actualIActionResult = JsonConvert.SerializeObject(iActionResult, new JsonSerializerSettings()
                    {
                        Formatting = Formatting.Indented
                    }).MinifyJson().PrettifyJson();
                    var expectedIActionResult =
                        @"
                            {
                              ""UrlHelper"": null,
                              ""ActionName"": ""AccessDenied"",
                              ""ControllerName"": ""Authorization"",
                              ""RouteValues"": null,
                              ""Permanent"": false,
                              ""PreserveMethod"": false,
                              ""Fragment"": null
                            }
                        ".MinifyJson().PrettifyJson();

                    Assert.AreEqual(expectedIActionResult, actualIActionResult);
                }
            });
        }