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

            listingToAdd.UserId             = Guid.Empty.ToString();
            listingToAdd.StateId            = "OH";
            listingToAdd.BathroomTypeId     = 1;
            listingToAdd.Nickname           = "Test Shack 1";
            listingToAdd.City               = "Columbus";
            listingToAdd.Rate               = 50M;
            listingToAdd.SquareFootage      = 100M;
            listingToAdd.HasElectric        = true;
            listingToAdd.HasHeat            = true;
            listingToAdd.ListingDescription = "Test Description";
            listingToAdd.ImageFileName      = "placeholder.png";

            repo.ListingInsert(listingToAdd);

            var loaded = repo.ListingGetById(7);

            Assert.IsNotNull(loaded);

            repo.ListingDelete(7);
            loaded = repo.ListingGetById(7);

            Assert.IsNull(loaded);
        }
Exemple #2
0
        public void NotFoundListingReturnsNull()
        {
            var     repo    = new ListingsRepositoryDapper();
            Listing listing = repo.ListingGetById(10000);

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

            listingToAdd.UserId             = Guid.Empty.ToString();
            listingToAdd.StateId            = "OH";
            listingToAdd.BathroomTypeId     = 1;
            listingToAdd.Nickname           = "Test Shack 1";
            listingToAdd.City               = "Columbus";
            listingToAdd.Rate               = 50M;
            listingToAdd.SquareFootage      = 100M;
            listingToAdd.HasElectric        = true;
            listingToAdd.HasHeat            = true;
            listingToAdd.ListingDescription = "Test Description";
            listingToAdd.ImageFileName      = "placeholder.png";

            repo.ListingInsert(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.ListingDescription = "Test Description Updated";
            listingToAdd.ImageFileName      = "updated.png";

            repo.ListingUpdate(listingToAdd);
            var updatedListing = repo.ListingGetById(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("Test Description Updated", updatedListing.ListingDescription);
            Assert.AreEqual("updated.png", updatedListing.ImageFileName);
        }
Exemple #4
0
        public void CanLoadListing()
        {
            var     repo    = new ListingsRepositoryDapper();
            Listing listing = repo.ListingGetById(1);

            Assert.IsNotNull(listing);

            //1, '00000000-0000-0000-0000-000000000000', 'OH', 1, 'Test shack 1', 'Cleveland', 120, 400, 0, 1, 'placeholder.png'
            Assert.AreEqual(1, listing.ListingId);
            Assert.AreEqual(Guid.Empty.ToString(), listing.UserId);
            Assert.AreEqual("OH", listing.StateId);
            Assert.AreEqual(1, listing.BathroomTypeId);
            Assert.AreEqual("Test shack 1", listing.Nickname);
            Assert.AreEqual("Cleveland", listing.City);
            Assert.AreEqual(100M, listing.Rate);
            Assert.AreEqual(400M, listing.SquareFootage);
            Assert.AreEqual(false, listing.HasElectric);
            Assert.AreEqual(true, listing.HasHeat);
            Assert.AreEqual("Description 1", listing.ListingDescription);
            Assert.AreEqual("placeholder.png", listing.ImageFileName);
        }