Beispiel #1
0
        public void Address_Repository_Get_ALL()
        {
            //Act
            var result = _objRepo.GetAll().ToList();

            //Assert
            Assert.IsNotNull(result);

            //Assert.AreEqual(3, result.Count);
            //Assert.AreEqual("123 First Street", result[0].Line1);
            //Assert.AreEqual("1122 Valley Road", result[1].Line1);
            //Assert.AreEqual("9000 East Blvd", result[2].Line1);
        }
        public void AddUpdate_Adds()
        {
            Assert.IsNull(target.GetAll("TestUserName"));

            target.AddUpdate("TestUserName", new Address());

            Assert.AreEqual(1, target.GetAll("TestUserName").Count());
        }
Beispiel #3
0
        public IHttpActionResult Post(Ad ad)
        {
            var LastAddressID = addressRepo.GetAll().Max(x => x.AddressId);

            var thisAddress = addressRepo.GetAll().Where(x => x.AddressId == LastAddressID).FirstOrDefault();

            ad.UserId    = thisAddress.UserId;
            ad.SpecId    = specificationRepo.GetAll().Max(x => x.SpecId);
            ad.AddressId = addressRepo.GetAll().Max(x => x.AddressId);

            adRepo.Insert(ad);
            string uri = Url.Link("GetAdById", new { id = ad.AdId });

            return(Created(uri, ad));
        }
        public List <DepartmentDomainModel> GetAllDepartment()
        {
            List <DepartmentDomainModel> departmentList = deptRepository.GetAll().Select(x => new DepartmentDomainModel {
                DepartmentId = x.DepartmentId, DepartmentName = x.DepartmentName
            }).ToList();

            return(departmentList);
        }
        public IHttpActionResult Post(Specification specification)
        {
            //Get Last Address id
            LastAddressId           = addressRepo.GetAll().Max(x => x.AddressId);
            specification.AddressId = LastAddressId;

            specificationRipo.Insert(specification);
            string uri = Url.Link("GetSpecificationById", new { id = specification.SpecId });

            return(Created(uri, specification));
        }
Beispiel #6
0
        public async Task Get_all_from_addresses()
        {
            // Arrange
            IAddressRepository repo = new AddressRepository(_fixture.Configuration.Connection);

            // Act
            var addresses = await repo.GetAll();

            // Assert
            Assert.NotNull(addresses);

            foreach (var address in addresses)
            {
                _fixture.Output.WriteLine($"{address.StreetAddress}, {address.City}, {address.PostalCode}");
            }
        }
Beispiel #7
0
 public IHttpActionResult Get()
 {
     return(Ok(addressRepo.GetAll()));
 }
 public IEnumerable <Address> Get()
 {
     return(_repo.GetAll());
 }
Beispiel #9
0
 public List <Address> GetAll()
 {
     return(_repository.GetAll());
 }
        public async Task <IEnumerable <DTOAddress> > GetAddress()
        {
            IEnumerable <Address> addresses = await _addressRepository.GetAll();

            return(_mapper.Map <IEnumerable <DTOAddress> >(addresses));
        }
Beispiel #11
0
        public void GetAllWorks()
        {
            List <Addresses> list          = new List <Addresses>();
            Customers        customerSaved = null;

            // arrange (use the context directly - we assume that works)
            var options = new DbContextOptionsBuilder <Project1Context>()
                          .UseInMemoryDatabase("db_address_test_getAll").Options;

            using (var db = new Project1Context(options));

            // act (for act, only use the repo, to test it)
            using (var db = new Project1Context(options))
            {
                var customerRepo = new CustomerRepository(db);
                var repo         = new AddressRepository(db);

                //Create customer
                Customers customer = new Customers {
                    FirstName = "First Name", LastName = "Last Name"
                };
                customerRepo.Save(customer);
                customerRepo.SaveChanges();

                for (int i = 0; i < 5; i++)
                {
                    Addresses address = new Addresses
                    {
                        CustomerId = customer.Id,
                        Address1   = $"Address 1 {i}",
                        Address2   = $"Address 2 {i}",
                        City       = $"City {i}",
                        State      = "ST",
                        Zipcode    = 12345
                    };
                    list.Add(address);
                    repo.Save(address);
                }
                repo.SaveChanges();
                customerSaved = customer;
            }

            // assert (for assert, once again use the context directly for verify.)
            using (var db = new Project1Context(options))
            {
                var repo = new AddressRepository(db);
                List <Addresses> Addresses = (List <Addresses>)repo.GetAll();

                Assert.Equal(list.Count, Addresses.Count);

                for (int i = 0; i < list.Count; i++)
                {
                    Assert.Equal(list[i].CustomerId, customerSaved.Id);
                    Assert.Equal(list[i].Address1, Addresses[i].Address1);
                    Assert.Equal(list[i].Address2, Addresses[i].Address2);
                    Assert.Equal(list[i].City, Addresses[i].City);
                    Assert.Equal(list[i].State, Addresses[i].State);
                    Assert.Equal(list[i].Zipcode, Addresses[i].Zipcode);
                }
            }
        }
        public void AddressRepository_GetAll()
        {
            List <AddressModel> lists = respository.GetAll();

            Assert.IsTrue(lists.Count > 0);
        }