public async void Undelete_ResponseIsDeny_ReturnsStatusForbidden()
            {
                // Arrange
                MessageBoxTestData testData = new MessageBoxTestData();
                Instance           instance = testData.GetSoftDeletedInstance();

                Mock <IApplicationRepository> applicationRepository = new Mock <IApplicationRepository>();

                Mock <IInstanceRepository> instanceRepository = new Mock <IInstanceRepository>();

                instanceRepository.Setup(s => s.GetOne(It.IsAny <string>(), It.IsAny <int>())).ReturnsAsync(instance);
                instanceRepository.Setup(s => s.Update(It.IsAny <Instance>())).ReturnsAsync((Instance i) => i);

                InstanceEvent instanceEvent = null;

                Mock <IInstanceEventRepository> instanceEventRepository = new Mock <IInstanceEventRepository>();

                instanceEventRepository.Setup(s => s.InsertInstanceEvent(It.IsAny <InstanceEvent>())).Callback <InstanceEvent>(p => instanceEvent = p)
                .ReturnsAsync((InstanceEvent r) => r);

                HttpClient client = GetTestClient(instanceRepository.Object, applicationRepository.Object, instanceEventRepository.Object);
                string     token  = PrincipalUtil.GetToken(-1);

                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                // Act
                HttpResponseMessage response = await client.PutAsync($"{BasePath}/sbl/instances/{testData.GetInstanceOwnerPartyId()}/{instance.Id.Split("/")[1]}/undelete", null);

                // Assert
                Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
                string content = await response.Content.ReadAsStringAsync();

                Assert.True(string.IsNullOrEmpty(content));
            }
            public async void Delete_HardDeleteSoftDeleted()
            {
                // Arrange
                MessageBoxTestData testData = new MessageBoxTestData();
                Instance           instance = testData.GetSoftDeletedInstance();

                Mock <IApplicationRepository> applicationRepository = new Mock <IApplicationRepository>();

                Instance storedInstance = null;

                Mock <IInstanceRepository> instanceRepository = new Mock <IInstanceRepository>();

                instanceRepository.Setup(s => s.GetOne(It.IsAny <string>(), It.IsAny <int>())).ReturnsAsync(instance);
                instanceRepository.Setup(s => s.Update(It.IsAny <Instance>())).Callback <Instance>(p => storedInstance = p).ReturnsAsync((Instance i) => i);

                InstanceEvent instanceEvent = null;

                Mock <IInstanceEventRepository> instanceEventRepository = new Mock <IInstanceEventRepository>();

                instanceEventRepository.Setup(s => s.InsertInstanceEvent(It.IsAny <InstanceEvent>())).Callback <InstanceEvent>(p => instanceEvent = p)
                .ReturnsAsync((InstanceEvent r) => r);

                HttpClient client = GetTestClient(instanceRepository.Object, applicationRepository.Object, instanceEventRepository.Object);

                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _validToken);

                // Act
                HttpResponseMessage response = await client.DeleteAsync($"{BasePath}/sbl/instances/{testData.GetInstanceOwnerPartyId()}/{instance.Id.Split("/")[1]}?hard=true");

                // Assert
                HttpStatusCode actualStatusCode = response.StatusCode;
                string         content          = await response.Content.ReadAsStringAsync();

                bool actualResult = JsonConvert.DeserializeObject <bool>(content);

                HttpStatusCode expectedStatusCode = HttpStatusCode.OK;
                bool           expectedResult     = true;

                Assert.Equal(expectedResult, actualResult);
                Assert.Equal(expectedStatusCode, actualStatusCode);
                Assert.True(storedInstance.Status.HardDeleted.HasValue);
            }