public void PostNewBug_WhenTextIsNull_ShouldReturn400()
        {
            IBugLoggerData data = Mock.Create<IBugLoggerData>();

            Bug bug = new Bug() { Text = null };

            var server = new InMemoryHttpServer(this.inMemoryServerUrl, data);

            var response = server.Post("/api/bugs", bug);

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
        }
        public void PostArticle_WhenTitleIsEmpty_ShouldReturn400()
        {
            IArticlesData data = Mock.Create<IArticlesData>();

            Article article = new Article() { DateCreated = DateTime.Now };
            Mock.Arrange(() => data.Articles.Add(Arg.IsAny<Article>()));

            var server = new InMemoryHttpServer(this.inMemoryServerUrl, data);
            var response = server.Post("/api/articles", article);

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
        }
        public void GetAll_WhenArticlesInDb_ShouldReturnStatus200AndNonEmptyContent()
        {
            IArticlesData data = Mock.Create<IArticlesData>();
            Article[] articles = { new Article() { DateCreated = DateTime.Now } };
            Mock.Arrange(() => data.Articles.All()).Returns(() => articles.AsQueryable());

            var server = new InMemoryHttpServer(this.inMemoryServerUrl, data);
            var response = server.Get("/api/articles");

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.IsNotNull(response.Content);
        }
        public void PostArticle_WhenValid_ShouldReturn201AndLocationHeader()
        {
            IArticlesData data = Mock.Create<IArticlesData>();

            Article article = new Article() { Title = "Test", DateCreated = DateTime.Now };
            Mock.Arrange(() => data.Articles.Add(Arg.IsAny<Article>()));

            var server = new InMemoryHttpServer(this.inMemoryServerUrl, data);
            var response = server.Post("/api/articles", article);

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
            Assert.IsNotNull(response.Headers.Location);
        }
        public void GetAll_WhenBugsInDb_ShouldReturnStatus200AndNonEmptyContent()
        {
            IBugLoggerData data = Mock.Create<IBugLoggerData>();
            Bug[] bugs = { new Bug(), new Bug(), new Bug() };

            Mock.Arrange(() => data.Bugs.All()).Returns(() => bugs.AsQueryable());

            var server = new InMemoryHttpServer(this.inMemoryServerUrl, data);

            var response = server.Get("/api/bugs");

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.IsNotNull(response.Content);
        }
        public void PostNewBug_WhenTextIsValid_ShouldReturn201AndLocationHeader()
        {
            IBugLoggerData data = Mock.Create<IBugLoggerData>();

            Bug bug = GetValidBug();

            Mock.Arrange(() => data.Bugs.Add(Arg.IsAny<Bug>()));

            var server = new InMemoryHttpServer(this.inMemoryServerUrl, data);

            var response = server.Post("/api/bugs", bug);

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
            Assert.IsNotNull(response.Headers.Location);
        }
Ejemplo n.º 7
0
        public void PostNewBug_WhenTextIsEmpty_ShouldReturn400()
        {
            IBugLoggerData data = Mock.Create <IBugLoggerData>();

            Bug bug = new Bug()
            {
                Text = ""
            };

            var server = new InMemoryHttpServer <Bug>(this.inMemoryServerUrl, data);

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

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
        }
Ejemplo n.º 8
0
        public void PostNewBug_WhenTextIsValid_ShouldReturn201AndLocationHeader()
        {
            IBugLoggerData data = Mock.Create <IBugLoggerData>();

            Bug bug = GetValidBug();

            Mock.Arrange(() => data.Bugs.Add(Arg.IsAny <Bug>()));

            var server = new InMemoryHttpServer <Bug>(this.inMemoryServerUrl, data);

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

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
            Assert.IsNotNull(response.Headers.Location);
        }
        public void PostNewBug_WhenTextIsNull_ShouldReturn400()
        {
            IRepository <Bug> repo = Mock.Create <IRepository <Bug> >();

            Bug bug = new Bug()
            {
                Text = null
            };

            var server = new InMemoryHttpServer <Bug>(this.inMemoryServerUrl, repo);

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

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
        }
        public void PostNewBug_WhenTextIsNull_ShouldReturn400()
        {
            IRepository<Bug> repo = Mock.Create<IRepository<Bug>>();

            Bug bug = new Bug()
            {
                Text = null
            };

            var server = new InMemoryHttpServer<Bug>(this.inMemoryServerUrl, repo);

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

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
        }
        public void GetCount_WhenBugsInDb_ShouldReturnStatus200AndNonEmptyContent()
        {
            IRepository<Bug> repo = Mock.Create<IRepository<Bug>>();
            Bug[] bugs = { new Bug(), new Bug(), new Bug() };

            Mock.Arrange(() => repo.All())
                .Returns(() => bugs.AsQueryable());

            var server = new InMemoryHttpServer<Bug>(this.inMemoryServerUrl, repo);

            var response = server.CreateGetRequest("/api/bugs?count=2");

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.IsNotNull(response.Content);
        }
        public void GetAll_WhenBugsInDb_ShouldReturnStatus200AndNonEmptyContent()
        {
            IRepository <Bug> repo = Mock.Create <IRepository <Bug> >();

            Bug[] bugs = { new Bug(), new Bug(), new Bug() };

            Mock.Arrange(() => repo.All())
            .Returns(() => bugs.AsQueryable());

            var server = new InMemoryHttpServer <Bug>(this.inMemoryServerUrl, repo);

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

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.IsNotNull(response.Content);
        }
        public void PostNewBug_WhenTextIsValid_ShouldReturn201AndLocationHeader()
        {
            IRepository<Bug> repo = Mock.Create<IRepository<Bug>>();

            Bug bug = GetValidBug();

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

            var server = new InMemoryHttpServer<Bug>(this.inMemoryServerUrl, repo);

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

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
            Assert.IsNotNull(response.Headers.Location);
        }
Ejemplo n.º 14
0
        public void PostNewBug_WhenTextIsValid_ShouldReturn201AndLocationHeader()
        {
            IRepository <Bug> repo = Mock.Create <IRepository <Bug> >();

            Bug bug = this.GetValidBug();

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

            var server = new InMemoryHttpServer <Bug>(this.inMemoryServerUrl, repo);

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

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
            Assert.IsNotNull(response.Headers.Location);
        }
        public void DeleteBug_WhenNotValidId_ShouldReturn400()
        {
            IRepository <Bug> repo = Mock.Create <IRepository <Bug> >();

            Bug[] bugs =
            {
                new Bug
                {
                    Id   = 1,
                    Text = "Some text for bug"
                }
            };

            Mock.Arrange(() => repo.All())
            .Returns(() => bugs.AsQueryable());

            var server   = new InMemoryHttpServer <Bug>(this.inMemoryServerUrl, repo);
            var response = server.CreateDeleteRequest("/api/bugs/10");

            Assert.AreEqual(HttpStatusCode.BadRequest, response.Result.StatusCode);
        }
        public void ChangeBugStatus_WhenNotValidData_ShouldReturn400()
        {
            IRepository <Bug> repo = Mock.Create <IRepository <Bug> >();

            Bug[] bugs =
            {
                new Bug
                {
                    Id   = 1,
                    Text = "Some text for bug"
                }
            };

            Mock.Arrange(() => repo.All())
            .Returns(() => bugs.AsQueryable());

            var server   = new InMemoryHttpServer <Bug>(this.inMemoryServerUrl, repo);
            var response = server.CreatePutRequest(string.Format("/api/bugs/2?status={0}", Status.Fixed));

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
        }
Ejemplo n.º 17
0
        public void GetAll_WhenBugsInDb_ShouldReturnStatus200AndNonEmptyContent()
        {
            IRepository <Bug> repo = Mock.Create <IRepository <Bug> >();

            Bug[] bugs =
            {
                new Bug
                {
                    Id      = 1,
                    LogDate = new DateTime(2013, 5, 5),
                    Status  = Status.Pending,
                    Text    = "Initial Bug found!"
                },
                new Bug
                {
                    Id      = 2,
                    LogDate = new DateTime(2011, 1, 2),
                    Status  = Status.Fixed,
                    Text    = "TestBug"
                },
                new Bug
                {
                    Id      = 22,
                    LogDate = new DateTime(2011, 1, 2),
                    Status  = Status.Fixed,
                    Text    = "TestBug"
                }
            };

            Mock.Arrange(() => repo.All())
            .Returns(() => bugs.AsQueryable());

            var server = new InMemoryHttpServer <Bug>(this.inMemoryServerUrl, repo);

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

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.IsNotNull(response.Content);
        }
        public void UpdateBugStatus_WhenBugIsValid_ShouldReturn200AndUpdatedBug()
        {
            IRepository<Bug> repo = Mock.Create<IRepository<Bug>>();

            Bug[] bugs = { new Bug(), new Bug(), new Bug() };

            Mock.Arrange(() => repo.All())
                .Returns(() => bugs.AsQueryable());

            var server = new InMemoryHttpServer<Bug>(this.inMemoryServerUrl, repo);

            var response = server.CreatePutRequest("/api/bugs/1", Status.Fixed);

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
            Assert.IsNotNull(response.Content);
        }
 public void GetBugsByDate_WhenDateIsCorrect_ShouldReturnOk()
 {
     var repo = Mock.Create<IRepository<Bug>>();
     var server = new InMemoryHttpServer<Bug>(this.inMemoryServerUrl,repo);
     var responce = server.CreateGetRequest("/api/bugs?date=20-02-2014");
     Assert.AreEqual(HttpStatusCode.OK, responce.StatusCode);
 }