public async void DeleteObject_Throw()
        {
            // Mock apis
            var writeApiMock = new Mock <IWriteApi>();
            var readApiMock  = new Mock <IReadApi>();

            writeApiMock.Setup(mock =>
                               mock.ObjectApi.DeleteObject(It.IsAny <string>())
                               ).Throws <InvalidOperationException>();

            var controller = new ObjectController(AppSettings, writeApiMock.Object, readApiMock.Object);

            var response = await controller.DeleteObject("ObjId", 4);

            Assert.IsType <BadRequestResult>(response);
        }
        public async void DeleteObject_Ok()
        {
            // Mock apis
            var writeApiMock = new Mock <IWriteApi>();
            var readApiMock  = new Mock <IReadApi>();

            writeApiMock.Setup(mock =>
                               mock.ObjectApi.DeleteObject(It.IsAny <string>())
                               ).ReturnsAsync(true);

            var controller = new ObjectController(AppSettings, writeApiMock.Object, readApiMock.Object);

            var response = await controller.DeleteObject("ObjId", 4);

            Assert.IsType <OkResult>(response);
        }
        public async Task Delete_Object_by_ObjectId(string json)
        {
            // Arrange
            var controller     = new ObjectController(_fixture.MongoRepository);
            var collectionName = "audit2";

            // Act
            var insertResult = await controller.InsertObjectWithNoId(new ItemRouteParameters()
            {
                DatabaseName = DATABASE_NAME, CollectionName = collectionName
            }, json, ResponseFormat.OnlyId);

            CreatedAtActionResult createdResult = ((CreatedAtActionResult)insertResult);
            JObject jsonObject2 = JObject.Parse(createdResult.Value.ToString());
            var     insertedId  = JArray.Parse(jsonObject2["ids"].ToString())[0].ToString();

            var firstGetResult = await controller.GetObject(new ItemRouteParameters()
            {
                DatabaseName = DATABASE_NAME, CollectionName = collectionName, Id = insertedId
            });

            OkObjectResult okGetResult = ((OkObjectResult)firstGetResult);

            Assert.Equal(200, okGetResult.StatusCode);

            var deleteResult = await controller.DeleteObject(new ItemRouteParameters()
            {
                DatabaseName = DATABASE_NAME, CollectionName = collectionName, Id = insertedId
            });

            OkResult okDeleteResult = ((OkResult)deleteResult);

            Assert.Equal(200, okDeleteResult.StatusCode);

            var secondGetResult = await controller.GetObject(new ItemRouteParameters()
            {
                DatabaseName = DATABASE_NAME, CollectionName = collectionName, Id = insertedId
            });

            ObjectResult notFoundGetResult = ((ObjectResult)secondGetResult);

            Assert.Equal(404, notFoundGetResult.StatusCode);
        }
        public async Task Delete_Object_by_Primitive_Id(string id, string json)
        {
            // Arrange
            var controller     = new ObjectController(_fixture.MongoRepository);
            var collectionName = "audit1";

            // Act
            var insertResult = await controller.InsertObjectWithId(new ItemRouteParameters()
            {
                DatabaseName = DATABASE_NAME, CollectionName = collectionName, Id = id
            }, json, ResponseFormat.OnlyId);

            var firstGetResult = await controller.GetObject(new ItemRouteParameters()
            {
                DatabaseName = DATABASE_NAME, CollectionName = collectionName, Id = id
            });

            OkObjectResult okGetResult = ((OkObjectResult)firstGetResult);

            Assert.Equal(200, okGetResult.StatusCode);

            var deleteResult = await controller.DeleteObject(new ItemRouteParameters()
            {
                DatabaseName = DATABASE_NAME, CollectionName = collectionName, Id = id
            });

            OkResult okDeleteResult = ((OkResult)deleteResult);

            Assert.Equal(200, okDeleteResult.StatusCode);

            var secondGetResult = await controller.GetObject(new ItemRouteParameters()
            {
                DatabaseName = DATABASE_NAME, CollectionName = collectionName, Id = id
            });

            ObjectResult notFoundGetResult = ((ObjectResult)secondGetResult);

            Assert.Equal(404, notFoundGetResult.StatusCode);
        }