Пример #1
0
		public void should_be_able_to_find_shortened_urls()
		{
			//given
			var store = new MongoUrlStore(this.connectionString);
			store.SaveUrl("http://somelongurl.com/", "http://shorturl/abc");

			//when
			var longUrl = store.GetUrlFor("http://shorturl/abc");

			//then
			Assert.Equal("http://somelongurl.com/", longUrl);
		}
Пример #2
0
		public async Task should_store_urls_in_mongo()
		{
			//when
			var store = new MongoUrlStore(this.connectionString);
			store.SaveUrl("http://somelongurl.com/", "http://shorturl/abc");

			//then
			var urlFromDB = await this.urlCollection
				.Find(Builders<BsonDocument>.Filter.Eq("url", "http://somelongurl.com/"))
				.FirstOrDefaultAsync();

			Assert.NotNull(urlFromDB);
			Assert.Equal(urlFromDB["shortenedUrl"], "http://shorturl/abc");
		}
        public void should_store_urls_in_mongo()
        {
            //when
            var store = new MongoUrlStore(connectionString);
            store.SaveUrl("http://somelongurl.com/", "http://shorturl/abc");

            //then
            var urlFromDB = urlCollection
                .Find(Query.EQ("url", "http://somelongurl.com/"))
                .FirstOrDefault();

            Assert.NotNull(urlFromDB);
            Assert.Equal(urlFromDB["shortenedUrl"], "http://shorturl/abc");
        }