Beispiel #1
0
        public void GetAllStatuses()
        {
            var result = _service.GetAll();
            var count  = result.Count();

            Assert.AreEqual(2, count);
        }
Beispiel #2
0
        public async Task GetAll_ItemsNotInCacheAlready_ReturnList()
        {
            // Arrange
            var item1 = new Status {
                Id = 1, Name = "Active"
            };
            var item2 = new Status {
                Id = 2, Name = "Passive"
            };
            var list = new List <Status> {
                item1, item2
            }.AsQueryable();

            repository.Setup(x => x.GetAllAsync(null)).ReturnsAsync(list);

            // Act
            var result = await service.GetAll();

            // Assert
            result.Should().BeEquivalentTo(list);

            var firstItem = result.FirstOrDefault();

            firstItem.Id.Should().Be(list.FirstOrDefault().Id);
            firstItem.Name.Should().Be(list.FirstOrDefault().Name);
        }
Beispiel #3
0
        public void Should_Delete_Status()
        {
            var fakeContext = new FakeContext("DeleteStatus");

            fakeContext.FillWith <Status>();

            using (var context = new MainContext(fakeContext.FakeOptions))
            {
                var repository   = new StatusRepository(context);
                var validator    = new StatusValidator();
                var service      = new StatusService(repository, validator);
                var currentCount = context.Status.Count();
                var newStatus    = new Status();
                newStatus.Name = "Testing";
                service.Create(newStatus);
                var createdStatus = (from u in service.GetAll()
                                     where u.Id != 0
                                     select u).FirstOrDefault();

                Assert.NotEqual(0, currentCount);
                service.Delete(createdStatus.Id);
                Assert.Equal(currentCount, context.Status.Count());
                repository.Dispose();
            }
        }
Beispiel #4
0
        public void GetAllStatuses()
        {
            //Arrage
            var statuses = new Mock <IStatusRepository>();

            statuses.Setup(s => s.GetAll()).Returns(new List <Status>
            {
                new Status()
                {
                    Id = 1, Title = "Status1"
                },
                new Status()
                {
                    Id = 2, Title = "Status2"
                },
                new Status()
                {
                    Id = 3, Title = "Status3"
                },
            });

            //Act
            var statusServer = new StatusService(statuses.Object);
            var statusesDto  = statusServer.GetAll().ToList();

            //Assert
            Assert.IsTrue(statusesDto.Count == 3);
        }
 public List <BllStatus> GetAllStatuses()
 {
     using (ServiceDB serviceDB = new ServiceDB())
     {
         IUnitOfWork    uow           = new UnitOfWork(serviceDB);
         IStatusService statusService = new StatusService(uow);
         return(statusService.GetAll().ToList());
     }
 }
Beispiel #6
0
        // GET api/<controller>
        public IHttpActionResult Get()
        {
            var statuses = Service.GetAll().OrderBy(e => e.Status).ToList();

            if (statuses.Count != 0)
            {
                return(Ok(MapService.MapMany <ITS_Status, StatusDTO>(statuses)));
            }
            return(ResponseMessage(new ResponseMessageService(HttpStatusCode.NotFound, "No statuses found.", Request.RequestUri.AbsoluteUri)));
        }
        public HttpResponseMessage GetAll()
        {
            try
            {
                ItemsResponse <StatusEntry> resp = new ItemsResponse <StatusEntry>();
                StatusService svc = new StatusService();

                resp.Items = svc.GetAll();
                return(Request.CreateResponse(HttpStatusCode.OK, resp));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
        public void Get_All_Statuses()
        {
            var mockSet = BuildMock();
            var mockCtx = new Mock <LibraryDbContext>();

            mockCtx.Setup(c => c.Statuses).Returns(mockSet.Object);

            var sut         = new StatusService(mockCtx.Object);
            var queryResult = sut.GetAll().ToList();

            queryResult.Should().AllBeOfType(typeof(Status));
            queryResult.Should().HaveCount(3);
            queryResult.Should().Contain(a => a.Name == "Available");
            queryResult.Should().Contain(a => a.Name == "Checked Out");
            queryResult.Should().Contain(a => a.Name == "Lost");
        }
Beispiel #9
0
        public void Should_Return_All_Status()
        {
            var fakeContext = new FakeContext("GetAllStatus");

            fakeContext.FillWith <Status>();

            using (var context = new MainContext(fakeContext.FakeOptions))
            {
                var statusCountIndDb = context.Status.Count();
                var repository       = new StatusRepository(context);
                var validator        = new StatusValidator();
                var service          = new StatusService(repository, validator);

                Assert.Equal(statusCountIndDb, service.GetAll().Count());
                repository.Dispose();
            }
        }
Beispiel #10
0
        public void Return_All_Statuses()
        {
            var options  = Utils.GetOptions(nameof(Return_All_Statuses));
            var statuses = Utils.SeedStatuses();

            using (var arrangeContext = new DeliverItContext(options))
            {
                arrangeContext.Statuses.AddRange(statuses);
                arrangeContext.SaveChanges();
            }

            using (var actContext = new DeliverItContext(options))
            {
                var sut    = new StatusService(actContext);
                var result = sut.GetAll();

                Assert.AreEqual(statuses.Count, result.Count);
                Assert.AreEqual(string.Join(",", statuses.Select(s => s.Name)), string.Join(",", result));
            }
        }
        public void StatusService_get_all()
        {
            var listStatus = new List <Status> {
                new Status {
                    IdStatus = Guid.NewGuid(), Name = "Status One"
                },
                new Status {
                    IdStatus = Guid.NewGuid(), Name = "Status Two"
                },
                new Status {
                    IdStatus = Guid.NewGuid(), Name = "Status Three"
                },
            };

            var repository = new Mock <IDataMasterRepository <Status> >();

            repository.Setup(x => x.GetAll()).Returns(listStatus);
            var statusService = new StatusService(repository.Object);

            var expected = statusService.GetAll();

            Assert.IsTrue(expected.Any());
            repository.Verify(x => x.GetAll(), Times.Once());
        }
Beispiel #12
0
 [Route("getStatuses")] //api/customer/product/getProducts
 public async Task <IActionResult> GetProducts()
 {
     return(Ok(await statusService.GetAll()));
 }
Beispiel #13
0
 public ActionResult <List <StatusDto> > GetStatuses()
 {
     return(_service.GetAll());
 }
Beispiel #14
0
 public void GetAllStatuses__ShouldCallRepoReadAll_Once()
 {
     _service.GetAll();
     _repoMock.Verify(repo => repo.ReadAll(), Times.Once);
 }
        public void StatusService_GetAll_CountEqualTo2()
        {
            _uow.Statuses.GetAll().Returns(_statusList);

            Assert.That(_statusService.GetAll().Count, Is.EqualTo(2));
        }
Beispiel #16
0
        public string All()
        {
            string jsonResponse = _statusService.GetAll();

            return(jsonResponse);
        }