Exemple #1
0
        public void CanDeleteListing()
        {
            Listing listingToAdd = new Listing();
            var     repo         = new ListingsRepositoryADO();

            listingToAdd.UserId             = "00000000-0000-0000-0000-000000000000";
            listingToAdd.StateId            = "OH";
            listingToAdd.Nickname           = "My Test Shack";
            listingToAdd.BathroomTypeId     = 1;
            listingToAdd.City               = "Columbus";
            listingToAdd.Rate               = 50M;
            listingToAdd.SquareFootage      = 100M;
            listingToAdd.HasElectric        = true;
            listingToAdd.HasHeat            = true;
            listingToAdd.ImageFileName      = "placeholder.png";
            listingToAdd.ListingDescription = "Description";


            repo.Insert(listingToAdd);

            var loaded = repo.GetById(7);

            Assert.IsNotNull(loaded);

            repo.Delete(7);
            loaded = repo.GetById(7);

            Assert.IsNull(loaded);
        }
Exemple #2
0
        public void NotFoundListingReturnsNull()
        {
            var repo    = new ListingsRepositoryADO();
            var listing = repo.GetById(100000);

            Assert.IsNull(listing);
        }
Exemple #3
0
        public void CanUpdateListing()
        {
            Listing listingToAdd = new Listing();
            var     repo         = new ListingsRepositoryADO();

            listingToAdd.UserId             = "00000000-0000-0000-0000-000000000000";
            listingToAdd.StateId            = "OH";
            listingToAdd.Nickname           = "My Test Shack";
            listingToAdd.BathroomTypeId     = 1;
            listingToAdd.City               = "Columbus";
            listingToAdd.Rate               = 50M;
            listingToAdd.SquareFootage      = 100M;
            listingToAdd.HasElectric        = true;
            listingToAdd.HasHeat            = true;
            listingToAdd.ImageFileName      = "placeholder.png";
            listingToAdd.ListingDescription = "Description";

            repo.Insert(listingToAdd);

            listingToAdd.StateId            = "KY";
            listingToAdd.Nickname           = "My Updated Shack";
            listingToAdd.BathroomTypeId     = 2;
            listingToAdd.City               = "Louisville";
            listingToAdd.Rate               = 25M;
            listingToAdd.SquareFootage      = 75M;
            listingToAdd.HasElectric        = false;
            listingToAdd.HasHeat            = false;
            listingToAdd.ImageFileName      = "updated.png";
            listingToAdd.ListingDescription = "updated";

            repo.Update(listingToAdd);

            var updatedListing = repo.GetById(7);

            Assert.AreEqual("KY", updatedListing.StateId);
            Assert.AreEqual("My Updated Shack", updatedListing.Nickname);
            Assert.AreEqual(2, updatedListing.BathroomTypeId);
            Assert.AreEqual("Louisville", updatedListing.City);
            Assert.AreEqual(25M, updatedListing.Rate);
            Assert.AreEqual(75M, updatedListing.SquareFootage);
            Assert.AreEqual(false, updatedListing.HasElectric);
            Assert.AreEqual(false, updatedListing.HasHeat);
            Assert.AreEqual("updated.png", updatedListing.ImageFileName);
            Assert.AreEqual("updated", updatedListing.ListingDescription);
        }
Exemple #4
0
        public void CanLoadListing()
        {
            var repo    = new ListingsRepositoryADO();
            var listing = repo.GetById(1);

            Assert.IsNotNull(listing);
            Assert.AreEqual(1, listing.ListingId);
            Assert.AreEqual("00000000-0000-0000-0000-000000000000", listing.UserId);
            Assert.AreEqual("OH", listing.StateId);
            Assert.AreEqual(3, listing.BathroomTypeId);
            Assert.AreEqual("Test shack 1", listing.Nickname);
            Assert.AreEqual("Cleveland", listing.City);
            Assert.AreEqual(120M, listing.Rate);
            Assert.AreEqual(400M, listing.SquareFootage);
            Assert.AreEqual(false, listing.HasElectric);
            Assert.AreEqual(true, listing.HasHeat);
            Assert.AreEqual("placeholder.png", listing.ImageFileName);
        }