예제 #1
0
        public void CanAddLocation()
        {
            IContactRepository sut   = new MemoryContactRepository();
            Contact            added = sut.Add(new Contact
            {
                FirstName = FIRST_NAME,
                LastName  = LAST_NAME
            });

            var location = sut.AddLocation(added.Id,
                                           new Location
            {
                Address1   = ADDRESS1,
                Address2   = ADDRESS2,
                City       = CITY,
                State      = STATE,
                PostalCode = POSTAL_CODE
            });

            sut[added.Id].Locations.Should().HaveCount(1);
            location.Address1.Should().BeEquivalentTo(ADDRESS1);
            location.Address2.Should().BeEquivalentTo(ADDRESS2);
            location.City.Should().BeEquivalentTo(CITY);
            location.State.Should().BeEquivalentTo(STATE);
            location.PostalCode.Should().BeEquivalentTo(POSTAL_CODE);
        }
예제 #2
0
        public void CanBeConstructed()
        {
            Action act = () =>
            {
                IContactRepository sut = new MemoryContactRepository();
                sut.Should().BeAssignableTo <MemoryContactRepository>();
            };

            act.ShouldNotThrow();
        }
예제 #3
0
        public void CanRemove()
        {
            IContactRepository sut   = new MemoryContactRepository();
            Contact            added = sut.Add(new Contact
            {
                FirstName = "Joe",
                LastName  = "Blaugh"
            });

            sut.Remove(added.Id);
            sut.All.Should().HaveCount(0);
        }
예제 #4
0
        public void CanAdd()
        {
            IContactRepository sut   = new MemoryContactRepository();
            Contact            added = sut.Add(new Contact
            {
                FirstName = "Joe",
                LastName  = "Blaugh"
            });

            sut.All.Should().HaveCount(1);
            sut[added.Id].FirstName.ShouldBeEquivalentTo("Joe");
            sut[added.Id].LastName.ShouldBeEquivalentTo("Blaugh");
        }
예제 #5
0
        public void CanUpdate()
        {
            IContactRepository sut   = new MemoryContactRepository();
            Contact            added = sut.Add(new Contact
            {
                FirstName = "Joe",
                LastName  = "Blaugh"
            });

            Contact updated = new Contact
            {
                Id        = added.Id,
                FirstName = "Jane",
                LastName  = "Daugh"
            };

            sut.Update(updated);

            sut.All.Should().HaveCount(1);
            sut[added.Id].FirstName.ShouldBeEquivalentTo("Jane");
            sut[added.Id].LastName.ShouldBeEquivalentTo("Daugh");
        }
예제 #6
0
        public void CanDeleteLocation()
        {
            IContactRepository sut   = new MemoryContactRepository();
            Contact            added = sut.Add(new Contact
            {
                FirstName = FIRST_NAME,
                LastName  = LAST_NAME
            });

            var location = sut.AddLocation(added.Id,
                                           new Location
            {
                Address1   = ADDRESS1,
                Address2   = ADDRESS2,
                City       = CITY,
                State      = STATE,
                PostalCode = POSTAL_CODE
            });

            sut.RemoveLocation(added.Id, location.Id);

            added.Locations.Should().HaveCount(0);
        }