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 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);
        }