public void Test_GetPackage_ById_ManyPackagesInCollection() { string connectionString = new Config().GetConnectionString(CommonStrings.Database.ConnectionStringName).ConnectionString; MongoUrlBuilder mub = new MongoUrlBuilder(connectionString); MongoPackageRepository repo = new MongoPackageRepository(connectionString); repo.Reset(); // add a random # of packages before the one we want int numToAdd = RandomDataHelper.Instance.Primitives.GetRandomInt(10); for (int i = 0; i < numToAdd; i++) { repo.AddPackage(RandomDataHelper.Instance.CreateRandomePackage()); } Package package = RandomDataHelper.Instance.CreateRandomePackage(); repo.AddPackage(package); // add a random # of packages after the one we want numToAdd = RandomDataHelper.Instance.Primitives.GetRandomInt(10); for (int i = 0; i < numToAdd; i++) { repo.AddPackage(RandomDataHelper.Instance.CreateRandomePackage()); } Package foundPackage = repo.GetPackage(package.Id); Assert.IsNotNull(foundPackage); CustomAssert.AreEqual(package, foundPackage); }
public void Test_GetPackage_ById_1PackageInCollection() { string connectionString = new Config().GetConnectionString(CommonStrings.Database.ConnectionStringName).ConnectionString; MongoUrlBuilder mub = new MongoUrlBuilder(connectionString); MongoPackageRepository repo = new MongoPackageRepository(connectionString); repo.Reset(); // first add a package and then ask try and get it back Package package = RandomDataHelper.Instance.CreateRandomePackage(); repo.AddPackage(package); Package foundPackage = repo.GetPackage(package.Id); Assert.IsNotNull(foundPackage); CustomAssert.AreEqual(package, foundPackage); }