public void GetAllWhenBugsInDbShouldReturnStatus200AndNonEmptyContent()
        {
            var mockUnitOfWork = Mock.Create <IBugTrackerData>();

            Bug[] bugs =
            {
                new Bug {
                    Id = 1, LogDate = DateTime.Today, Status = Status.Pending, Text = "SomeText"
                },
                new Bug {
                    Id = 2, LogDate = DateTime.Today, Status = Status.Pending, Text = "SomeText"
                },
                new Bug {
                    Id = 2, LogDate = DateTime.Today, Status = Status.Pending, Text = "SomeText"
                }
            };

            Mock.Arrange(() => mockUnitOfWork.Bugs).Returns((IRepository <Bug>)bugs.AsQueryable());

            var server = new InMemoryHttpServer <Bug>(InMemoryServerUrl, mockUnitOfWork);

            var response = server.CreateGetRequest("/api/Bugs/All");

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.IsNotNull(response.Content);
        }
        public void PostNewBugWhenTextIsNullShouldReturn400()
        {
            var repo = Mock.Create <IBugTrackerData>();

            var bug = new Bug {
                Text = null
            };

            var server = new InMemoryHttpServer <Bug>(InMemoryServerUrl, repo);

            var response = server.CreatePostRequest("/api/Bugs/Log", bug);

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
        }
        public void PostNewBugWhenTextIsValidShouldReturn201AndLocationHeader()
        {
            var mockUnitOfWork = Mock.Create <IBugTrackerData>();

            var bug = this.GetValidBug();

            Mock.Arrange(() => mockUnitOfWork.Bugs.Add(Arg.IsAny <Bug>())).Returns(() => bug);

            var server = new InMemoryHttpServer <Bug>(InMemoryServerUrl, mockUnitOfWork);

            var response = server.CreatePostRequest("/api/Bugs/Log", bug);

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
            Assert.IsNotNull(response.Headers.Location);
        }