public TestExampleEntityController()
        {
            MockServiceSetup.SetupHttpContext();

            this._exampleEntities           = new List <ExampleEntityDto>(MockServiceSetup.SetupExampleEntities());
            this._exampleEntitiesController = new ExampleEntityController(this.SetupExampleEntitiesService(), MockServiceSetup.SetupLogger());
        }
        public async Task ExampleEntity_Update_Test()
        {
            var getResult = await this._exampleEntitiesController.Get(3) as OkNegotiatedContentResult <ExampleEntityDto>;

            Assert.IsNotNull(getResult);
            Assert.IsNotNull(getResult.Content);

            // Need to reset HttpContext since the above request killed it.
            MockServiceSetup.SetupHttpContext();

            var exampleEntity = getResult.Content;
            var newName       = "Renamed ExampleEntity " + exampleEntity.Id;

            exampleEntity.ExampleProperty = newName;

            var saveResult = await this._exampleEntitiesController.Put(exampleEntity.Id, exampleEntity) as OkNegotiatedContentResult <SaveResult <ExampleEntityDto> >;

            Assert.IsNotNull(saveResult);
            Assert.IsNotNull(saveResult.Content);
            Assert.IsNotNull(saveResult.Content.Data);
            Assert.AreEqual(saveResult.Content.Data.ExampleProperty, newName);

            // Need to reset HttpContext since the above request killed it.
            MockServiceSetup.SetupHttpContext();

            getResult = await this._exampleEntitiesController.Get(3) as OkNegotiatedContentResult <ExampleEntityDto>;

            Assert.IsNotNull(getResult);
            Assert.IsNotNull(getResult.Content);
            Assert.AreEqual(getResult.Content.ExampleProperty, newName);
        }
        public static IEnumerable <ExampleEntityDto> SetupExampleEntities()
        {
            var divisions = new List <ExampleEntityDto>();

            for (var i = 1; i <= 5; i++)
            {
                divisions.Add(MockServiceSetup.SetupExampleEntityDto(i));
            }

            return(divisions);
        }