public void CustomerMasterRepositoryTest002_CreateFindDeleteSync_ExpectNoExceptions() { if (repo.Count() > 0) { repo.DeleteAll(); } Customer entity = new Customer("CustomerMasterRepositoryTest002_cname", "1-800-start"); repo.Add(entity); long newCount = repo.Count(); Assert.Equal(1, newCount); var fetch = repo.GetByEntityId(entity.entityid); Assert.NotNull(fetch); // Assert.Equal(fetch,entity); // Test search API var searchresult = repo.Get(e => e.phone == "1-800-start"); Assert.Equal(1, searchresult.Count); // Test Update API entity.phone = "1-800-updated"; repo.Update(entity); Assert.Equal(1, (repo.Get(e => e.phone == "1-800-updated")).Count); repo.Delete(entity.entityid); Assert.Throws <Exception>(() => fetch = repo.GetByEntityId(entity.entityid)); }
public void CanDeleteDocument() { var customerRepository = new MongoRepository <Customer>(); customerRepository.Add(this.TestCustomers); customerRepository.Delete(this.TestCustomers[0]); var document = customerRepository.GetById(this.TestCustomers[0].Id); document.ShouldBeNull(); customerRepository.Delete(this.TestCustomers); }
public void Delete_Normal_IsTrue() { var user = new User { Age = 111, Name = "chengongeee" }; MongoRepository.Add(user); var result = MongoRepository.Delete(user); Assert.IsTrue(result); }
public void Delete_Normal_IsTrue() { var log = new Logs { LogName = "OtherLog", Msg = "Delete_log_Add于:" + DateTime.Now.ToString() }; MongoRepository.Add(log); var result = MongoRepository.Delete(log); Assert.IsTrue(result); }
/// <summary> /// MongoDB'den içerik silmeye yarar /// </summary> /// <param name="id">içerik id</param> /// <returns></returns> private bool DeleteImageMongo(int id) { using (MongoRepository <ImageMongoModel> mongoRepository = new MongoRepository <ImageMongoModel>()) { return(mongoRepository.Delete(x => x.ParentId == id && x.DatabaseName.Equals("ImageApp") && x.TableName.Equals("Images"))); } }
public static string DeleteFeedUrl(string RssId, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings) { try { MongoRepository _RssRepository = new MongoRepository("Rss", _appSettings); List <Domain.Socioboard.Models.Mongo.Rss> lstRss = new List <Domain.Socioboard.Models.Mongo.Rss>(); var ret = _RssRepository.Find <Domain.Socioboard.Models.Mongo.Rss>(t => t.strId == RssId); var task = Task.Run(async() => { return(await ret); }); lstRss = task.Result.ToList(); Domain.Socioboard.Models.RssFeedUrl feedurl = dbr.FindSingle <Domain.Socioboard.Models.RssFeedUrl>(t => t.rssurl.Equals(lstRss.First().RssFeedUrl) && t.ProfileId == lstRss.First().ProfileId); if (feedurl != null) { dbr.Delete <Domain.Socioboard.Models.RssFeedUrl>(feedurl); } var builders = Builders <Domain.Socioboard.Models.Mongo.Rss> .Filter; FilterDefinition <Domain.Socioboard.Models.Mongo.Rss> filter = builders.Eq("strId", RssId); _RssRepository.Delete <Domain.Socioboard.Models.Mongo.Rss>(filter); return("success"); } catch (Exception ex) { return("Error"); } }
public void CustomIDTest() { var x = new MongoRepository <CustomIDEntity>(); var xm = new MongoRepositoryManager <CustomIDEntity>(); x.Add(new CustomIDEntity() { Id = "aaa" }); Assert.IsTrue(xm.Exists); Assert.IsInstanceOfType(x.GetById("aaa"), typeof(CustomIDEntity)); Assert.AreEqual("aaa", x.GetById("aaa").Id); x.Delete("aaa"); Assert.AreEqual(0, x.Count()); var y = new MongoRepository <CustomIDEntityCustomCollection>(); var ym = new MongoRepositoryManager <CustomIDEntityCustomCollection>(); y.Add(new CustomIDEntityCustomCollection() { Id = "xyz" }); Assert.IsTrue(ym.Exists); Assert.AreEqual(ym.Name, "MyTestCollection"); Assert.AreEqual(y.CollectionName, "MyTestCollection"); Assert.IsInstanceOfType(y.GetById("xyz"), typeof(CustomIDEntityCustomCollection)); y.Delete("xyz"); Assert.AreEqual(0, y.Count()); }
public void Should_ClearTheEntireRepository() { SettingsReader <DbSettings> reader = new SettingsReader <DbSettings>(); DbSettings settings = reader.Read(@"dbsettings_test.json"); IDatabase <IMongoDatabase> database = new MongoDatabase <IMongoDatabase>(); database.Init(settings); Assert.NotNull(database); IMongoDatabase db = database.GetDatabase(); Assert.NotNull(db); Assert.NotNull(db.Client); Assert.NotNull(db.Settings); IRepository <User> repository = new MongoRepository <User>(database); Assert.IsNotNull(repository); List <User> allUsers = repository.GetAll(); Assert.NotNull(allUsers); foreach (User currentUser in allUsers) { repository.Delete(x => x.Id == currentUser.Id); } List <User> allUsersShouldBeEmpty = repository.GetAll(); Assert.NotNull(allUsersShouldBeEmpty); Assert.AreEqual(0, allUsersShouldBeEmpty.Count); }
public void Delete_Success() { var entity = new MongoTestEntity() { Bool = false, Number = 1, String = "String" }; entity = Repository.Create(entity); Repository.Delete(entity); entity = Repository.Read(entity.Id); Assert.IsNull(entity); }
public void CanAddDocument() { var customerRepository = new MongoRepository <Customer>(); customerRepository.Add(this.TestCustomers[0]); this.TestCustomers[0].Id.ShouldNotBeNullOrWhiteSpace(); customerRepository.Delete(this.TestCustomers[0]); }
public IActionResult DeleteinstagramFeed(string profileId, string FeedId) { MongoRepository _DeleteistagramFeeds = new MongoRepository("InstagramFeed", _appSettings); var builders = Builders <Domain.Socioboard.Models.Mongo.InstagramFeed> .Filter; FilterDefinition <Domain.Socioboard.Models.Mongo.InstagramFeed> filter = builders.Eq("FeedId", FeedId); _DeleteistagramFeeds.Delete <Domain.Socioboard.Models.Mongo.InstagramFeed>(filter); return(Ok()); }
public IActionResult deleteTwtFeed(string profileId, string messageId) { MongoRepository _DeleteTwtFeeds = new MongoRepository("MongoTwitterFeed", _appSettings); var builders = Builders <Domain.Socioboard.Models.Mongo.MongoTwitterFeed> .Filter; FilterDefinition <Domain.Socioboard.Models.Mongo.MongoTwitterFeed> filter = builders.Eq("messageId", messageId); _DeleteTwtFeeds.Delete <Domain.Socioboard.Models.Mongo.MongoTwitterFeed>(filter); return(Ok()); }
/// <summary> /// 初始化添加预定义权限值 /// </summary> /// <param name="app"></param> public static void InitPermission(IApplicationBuilder app) { //验证权限值是否重复 ValidPermissions(); //反射被标记的Controller和Action _mongoRepository = (MongoRepository)app.ApplicationServices.GetService(typeof(MongoRepository)); var permList = new List <MenuAction>(); var actions = typeof(PermissionUtil).Assembly.GetTypes() .Where(t => typeof(Controller).IsAssignableFrom(t) && !t.IsAbstract) .SelectMany(t => t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)); //遍历集合整理信息 foreach (var action in actions) { var permissionAttribute = action.GetCustomAttributes(typeof(PermissionAttribute), false).ToList(); if (!permissionAttribute.Any()) { continue; } var codes = permissionAttribute.Select(a => ((PermissionAttribute)a).Code).ToArray(); var controllerName = action?.ReflectedType?.Name.Replace("Controller", "").ToLower(); var actionName = action.Name.ToLower(); foreach (var item in codes) { if (permList.Exists(c => c.Code == item)) { var menuAction = permList.FirstOrDefault(a => a.Code == item); menuAction?.Url.Add($"{controllerName}/{actionName}".ToLower()); } else { var perm = new MenuAction { Id = item.ToString().EncodeMd5String().ToObjectId(), CreateDateTime = DateTime.Now, Url = new List <string> { $"{controllerName}/{actionName}".ToLower() }, Code = item, Name = ((PermCode)item).GetDisplayName() ?? ((PermCode)item).ToString() }; permList.Add(perm); } } PermissionUrls.TryAdd($"{controllerName}/{actionName}".ToLower(), codes); } //业务功能持久化 _mongoRepository.Delete <MenuAction>(a => true); _mongoRepository.BatchAdd(permList); }
public async Task <IActionResult> Buy([FromBody] BuyOrderViewModel model) { var userClaims = _caller.Claims.Single(c => c.Type == "id"); var user = mongoRepositoryUserInfo.Where(u => u.Username == userClaims.Value).FirstOrDefault(); var order = mongoRepositoryOrder.Where(o => o.TransactionId == model.TransactionId).FirstOrDefault(); var tx = await this.nethereumService.BuyOrder(user.PrivateKey, model.TransactionId, order.Price); mongoRepositoryOrder.Delete(o => o.TransactionId == model.TransactionId); return(new OkObjectResult(tx)); }
public void AddAndUpdateTest() { var customerRepository = new MongoRepository <Customer>(); var customerManager = new MongoRepositoryManager <Customer>(); //_customerManager.Exists.ShouldBeFalse(); var customer = new Customer(); customer.FirstName = "Bob"; customer.LastName = "Dillon"; customer.Phone = "0900999899"; customer.Email = new CustomerEmail("*****@*****.**"); customer.HomeAddress = new Address { Address1 = "North kingdom 15 west", Address2 = "1 north way", City = "George Town", Country = "Alaska", PostCode = "40990" }; customerRepository.Add(customer); customerManager.Exists.ShouldBeTrue(); customer.Id.ShouldNotBeNullOrWhiteSpace(); // fetch it back var alreadyAddedCustomer = customerRepository.Where(c => c.FirstName == "Bob").Single(); alreadyAddedCustomer.ShouldNotBeNull(); customer.FirstName.ShouldBe(alreadyAddedCustomer.FirstName); customer.HomeAddress.Address1.ShouldBe(alreadyAddedCustomer.HomeAddress.Address1); alreadyAddedCustomer.Phone = "10110111"; alreadyAddedCustomer.Email = new CustomerEmail("*****@*****.**"); customerRepository.Update(alreadyAddedCustomer); // fetch by id now var updatedCustomer = customerRepository.GetById(customer.Id); updatedCustomer.ShouldNotBeNull(); alreadyAddedCustomer.Phone.ShouldBe(updatedCustomer.Phone); alreadyAddedCustomer.Email.Value.ShouldBe(updatedCustomer.Email.Value); customerRepository.Exists(c => c.HomeAddress.Country == "Alaska").ShouldBeTrue(); customerRepository.Delete(updatedCustomer); var exists = customerRepository.GetById(updatedCustomer.Id); exists.ShouldBeNull(); customerRepository.DeleteAll(); }
public async Task DeleteAsync(ClientEntity entity) { try { _collection.Delete(entity); } catch (Exception e) { throw new ApplicationException(string.Format("Mongo driver failure: {0}", e)); } }
public void CanCountDocuments() { var customerRepository = new MongoRepository <Customer>(); customerRepository.Add(this.TestCustomers); var count = customerRepository.Count(); count.ShouldBe(this.TestCustomers.Count); customerRepository.Delete(this.TestCustomers); }
public static async Task <bool> ExcluiUsuario(UsuarioModel usuario) { try { await Task.Run(() => _repo.Delete <UsuarioModel>(usuario)); return(true); } catch (Exception) { throw; } }
public void CanCheckIfDocumentExists() { var customerRepository = new MongoRepository <Customer>(); customerRepository.Add(this.TestCustomers); customerRepository.Count().ShouldBe(this.TestCustomers.Count); var exists = customerRepository.Exists(x => x.Id == this.TestCustomers[0].Id); exists.ShouldBeTrue(); customerRepository.Delete(this.TestCustomers); }
public void RemoveStrategies(string instrumentId) { InstrumentStrategy instrumentStrategy = GetInstrumentStrategy(instrumentId); if (instrumentStrategy == null) { return; } instrumentStrategies.Remove(instrumentStrategy); dictStrategies.Remove(instrumentId); strategyRepo.Delete(instrumentStrategy); }
/// <summary> /// 根据Id删除 /// </summary> /// <param name="roleId"></param> /// <returns></returns> public ServiceResult DeleteById(string roleId) { var roleIdObject = roleId.ToObjectId(); var isExists = _mongoRepository.Exists <Administrator>(a => a.RoleIds.Contains(roleIdObject)); if (isExists) { return(ServiceResult.IsFailed("无法删除已分配关联用户的数据")); } return(_mongoRepository.Delete <Role>(a => a.Id == roleIdObject) > 0 ? ServiceResult.IsSuccess(AccountConstString.OperateSuccess) : ServiceResult.IsFailed(AccountConstString.OperateFailed)); }
public static void DeleteTask(string taskId, ILogger _logger, Helper.Cache _redisCache, Helper.AppSettings _appSettings) { try { MongoRepository taskmongorepo = new MongoRepository("Tasks", _appSettings); MongoRepository taskcommentmongorepo = new MongoRepository("TaskComments", _appSettings); taskmongorepo.Delete <Tasks>(t => t.strId == taskId); taskcommentmongorepo.DeleteMany <TaskComments>(t => t.taskId == taskId); } catch (Exception) { throw; } }
public static bool DeletePost(string postId, Helper.AppSettings _settings) { try { MongoRepository mongorepo = new MongoRepository("SavedFeedsManagement", _settings); FilterDefinition <BsonDocument> filter = new BsonDocument("strId", postId); mongorepo.Delete(filter); return(true); } catch { return(false); } }
/// <summary> /// /// </summary> /// <param name="feedId"></param> /// <param name="appSettings"></param> /// <returns></returns> public static string DeleteContentfeedsRepo(string feedId, Helper.AppSettings appSettings) { try { var contentFeedsRepo = new MongoRepository("RssNewsContentsFeeds", appSettings); var builders = Builders <RssNewsContentsFeeds> .Filter; var filter = builders.Eq("Link", feedId); contentFeedsRepo.Delete(filter); return("success"); } catch (Exception) { return("Error"); } }
public static string DeleteContentfeedsRepo(string feedId, Helper.AppSettings _appSettings) { try { MongoRepository _ContentFeedsRepo = new MongoRepository("RssNewsContentsFeeds", _appSettings); var builders = Builders <Domain.Socioboard.Models.Mongo.RssNewsContentsFeeds> .Filter; FilterDefinition <Domain.Socioboard.Models.Mongo.RssNewsContentsFeeds> filter = builders.Eq("Link", feedId); _ContentFeedsRepo.Delete <Domain.Socioboard.Models.Mongo.RssNewsContentsFeeds>(filter); return("success"); } catch (Exception ex) { return("Error"); } }
public static string DeleteFeedUrl(string RssId, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings) { try { MongoRepository _RssRepository = new MongoRepository("Rss", _appSettings); var builders = Builders <Domain.Socioboard.Models.Mongo.Rss> .Filter; FilterDefinition <Domain.Socioboard.Models.Mongo.Rss> filter = builders.Eq("strId", RssId); _RssRepository.Delete <Domain.Socioboard.Models.Mongo.Rss>(filter); return("success"); } catch (Exception ex) { return("Error"); } }
public static bool DeleteComment(string commentId, Helper.AppSettings _settings) { MongoRepository mongorepo = new MongoRepository("SavedFeedsComments", _settings); try { FilterDefinition <BsonDocument> filter = new BsonDocument("strCommentId", commentId); mongorepo.Delete(filter); return(true); } catch { return(false); } }
public async Task Delete(string id) { if (string.IsNullOrWhiteSpace(id)) { throw new Exception($"no id has been given."); } var mongoRepository = new MongoRepository <Translation> (new BaseDbBuilder()); Log.Debug($"Delete: Deleting '{id}'"); mongoRepository.Delete(id); StatusCode(StatusCodes.Status202Accepted); }
public static string DeletePageShareathon(string PageShareathodId, Helper.AppSettings _appSettings) { try { MongoRepository _ShareathonRepository = new MongoRepository("Shareathon", _appSettings); var builders = Builders <Domain.Socioboard.Models.Mongo.PageShareathon> .Filter; FilterDefinition <Domain.Socioboard.Models.Mongo.PageShareathon> filter = builders.Eq("strId", PageShareathodId); _ShareathonRepository.Delete <Domain.Socioboard.Models.Mongo.PageShareathon>(filter); return("success"); } catch (Exception ex) { return("Error"); } }
public bool ChangeProjectRights(Identity projectId, IEnumerable <ProjectRights> newProjectRights) { var project = _projectRepository.Read(projectId.ToMongoIdentity()); if (project == null) { throw new EntityNotFoundException { Id = projectId }; } var filter = Builders <MongoSecurityRights> .Filter.Eq(x => x.ProjectId, projectId.ToMongoIdentity()); var oldRights = _securityRightsRepository.Find(filter).ToArray(); _securityRightsRepository.Delete(filter); try { var mongoRights = newProjectRights.Select(x => new MongoSecurityRights { ProjectId = projectId.ToMongoIdentity(), UserId = x.UserId.ToMongoIdentity(), CanChangeProjectRights = x.CanChangeProjectRights, CanChangeRequirements = x.CanChangeRequirements, CanChangeUseCases = x.CanChangeUseCases, CanViewProject = x.CanViewProject, IsAdministrator = x.IsAdministrator, }); foreach (var mongoRight in mongoRights) { _securityRightsRepository.Create(mongoRight); } } catch (EntityNotFoundException) { foreach (var right in oldRights) { _securityRightsRepository.Create(right); } throw; } return(true); }
public static void DeleteRoom(Room room) { var mongoRepository = new MongoRepository<Room>(ConnectionString); mongoRepository.Delete(room); }
public static ParameterSet LoadOrCreateDummy() { var repo = new MongoRepository<ParameterSet>(); var defaultName = "DEFAULT"; var ps = repo.FirstOrDefault(p => p.Name == defaultName); if (ps != null) { repo.Delete(ps); } ps = new ParameterSet { Name = defaultName, Parameters = new List<Parameter> { new Parameter() { Name = "Server-ID", TagId = ParameterTagId.ServerId, IsActive = true, IsAutoIncrement = true, IsWriteOnly = false, IsPartOfMatrixCode = true, TargetValue = "0A-01-44-5A-47-01-02-62-5A-17", ObisCode = RegisterIds.DeviceId.ToHexString("-") }, new Parameter() { Name = "Hersteller Seriennummer", TagId = ParameterTagId.ManufacturerSerialNumber, IsActive = true, IsAutoIncrement = false, TargetValue = "", // derived from serverId ObisCode = VendorSpecificRegisterIds.ManufacturerSerialNumber.ToHexString("-") }, new Parameter() { Name = "Reallin Barcode", TagId = ParameterTagId.PcbBarCode, ObisCode = "", IsNameplateOnly = true, TargetValue = "" }, new Parameter() { Name = "Messbetriebsart", TagId = ParameterTagId.MeasurementMode, IsActive = true, TargetValue = "MM2", ObisCode = VendorSpecificRegisterIds.MeasurementMode.ToHexString("-") }, new Parameter() { Name="ECC Schlüssel generieren", TagId = ParameterTagId.GenerateKeys, IsActive = true, TargetValue = "True", ObisCode = VendorSpecificRegisterIds.GenerateKeys.ToHexString("-"), IsWriteOnly = true }, new Parameter() { Name = "ECC Public Key", TagId = ParameterTagId.PublicKey, IsActive = true, IsReadOnly = true, IsPartOfMatrixCode = true, TargetValue = "", ObisCode = RegisterIds.PublicKeySignature.ToHexString("-") }, new Parameter() { Name = "Initialer AES Key M", TagId = ParameterTagId.InitialKeyM, IsActive = true, IsRandomTargetValue = true, TargetValue = "", ObisCode = RegisterIds.SymmetricInitialKey.ToHexString("-") }, new Parameter() { Name = "Grid Option", TagId = ParameterTagId.GridOption, IsActive = true, TargetValue = "True", ObisCode = RegisterIds.GridOptionEnabled.ToHexString("-") }, new Parameter() { Name = "Tariff Option", TagId = ParameterTagId.TarifOptionActive, IsActive = true, TargetValue = "True", ObisCode = RegisterIds.TariffOptionEnabled.ToHexString("-") }, new Parameter() { Name = "Tariff Configuration", TagId = ParameterTagId.InverseTariffControl, ObisCode = ObisEdl.DzgTerminalControlReverse.ToHexString("-"), IsActive = true, TargetValue = "True", }, new Parameter() { Name = "PIN Code", TagId = ParameterTagId.PinCode, IsActive = true, IsRandomTargetValue = true, TargetValue = "1111", ObisCode = RegisterIds.PinCode.ToHexString("-") }, new Parameter() { Name = "PIN Code aktiv", TagId = ParameterTagId.PinCodeActive, IsActive = true, TargetValue = "False", ObisCode = RegisterIds.PinCodeEnabled.ToHexString("-") }, new Parameter() { Name = "Baudrate konfigurierbar", TagId = ParameterTagId.BaudRateConfigurable, IsActive = true, TargetValue = "False", ObisCode = RegisterIds.BaudrateOptionEnabled.ToHexString("-") }, new Parameter() { Name="Baudrate", TagId = ParameterTagId.BaudRate, IsActive = false, TargetValue = "921600", ObisCode = RegisterIds.Baudrate.ToHexString("-") }, new Parameter() { Name = "Firmware Dateiname", TagId = ParameterTagId.FirmwareFilename, IsActive = false, TargetValue = "BASEMETER_v157.fwpk", IsWriteOnly = true }, new Parameter() { Name = "Typenbezeichnung", TagId = ParameterTagId.Type, IsActive = true, TargetValue = "DWSB12.2TH", IsNameplateOnly = true, }, new Parameter() { Name = "Eigentumsnummer", TagId = ParameterTagId.Eigentumsnummer, IsActive = true, TargetValue = "40000", IsNameplateOnly = true, IsAutoIncrement = true } } }; repo.Add(ps); return ps; }
public void RepositoryDeleteTest() { var target = new MongoContext(); var repository = new MongoRepository<Employee>(target); Employee employee = null; Yekzen.QualityTools.UnitTest.ExceptionAssert.InconclusiveWhenThrows<UnreachableException>(() => { employee = InsertInternal(repository); }); if(string.IsNullOrEmpty(employee.Id)) Assert.Inconclusive("Insert failed."); repository.Delete(p => p.Id == employee.Id); employee = repository.Single(p => p.Id == employee.Id); Assert.IsNull(employee); }
public void BatchTest() { IRepository<Customer> _customerRepo = new MongoRepository<Customer>(); var custlist = new List<Customer>(new Customer[] { new Customer() { FirstName = "Customer A" }, new Customer() { FirstName = "Client B" }, new Customer() { FirstName = "Customer C" }, new Customer() { FirstName = "Client D" }, new Customer() { FirstName = "Customer E" }, new Customer() { FirstName = "Client F" }, new Customer() { FirstName = "Customer G" }, }); //Insert batch _customerRepo.Add(custlist); var count = _customerRepo.Count(); Assert.AreEqual(7, count); foreach (Customer c in custlist) Assert.AreNotEqual(new string('0', 24), c.Id); //Update batch foreach (Customer c in custlist) c.LastName = c.FirstName; _customerRepo.Update(custlist); foreach (Customer c in _customerRepo) Assert.AreEqual(c.FirstName, c.LastName); //Delete by criteria _customerRepo.Delete(f => f.FirstName.StartsWith("Client")); count = _customerRepo.Count(); Assert.AreEqual(4, count); //Delete specific object _customerRepo.Delete(custlist[0]); //Test AsQueryable var selectedcustomers = from cust in _customerRepo where cust.LastName.EndsWith("C") || cust.LastName.EndsWith("G") select cust; Assert.AreEqual(2, selectedcustomers.ToList().Count); count = _customerRepo.Count(); Assert.AreEqual(3, count); //Drop entire repo new MongoRepositoryManager<Customer>().Drop(); count = _customerRepo.Count(); Assert.AreEqual(0, count); }
public void CustomIDTypeTest() { var xint = new MongoRepository<IntCustomer, int>(); xint.Add(new IntCustomer() { Id = 1, Name = "Test A" }); xint.Add(new IntCustomer() { Id = 2, Name = "Test B" }); var yint = xint.GetById(2); Assert.AreEqual(yint.Name, "Test B"); xint.Delete(2); Assert.AreEqual(1, xint.Count()); }
public void CustomIDTest() { var x = new MongoRepository<CustomIDEntity>(); var xm = new MongoRepositoryManager<CustomIDEntity>(); x.Add(new CustomIDEntity() { Id = "aaa" }); Assert.IsTrue(xm.Exists); Assert.IsInstanceOfType(x.GetById("aaa"), typeof(CustomIDEntity)); Assert.AreEqual("aaa", x.GetById("aaa").Id); x.Delete("aaa"); Assert.AreEqual(0, x.Count()); var y = new MongoRepository<CustomIDEntityCustomCollection>(); var ym = new MongoRepositoryManager<CustomIDEntityCustomCollection>(); y.Add(new CustomIDEntityCustomCollection() { Id = "xyz" }); Assert.IsTrue(ym.Exists); Assert.AreEqual(ym.Name, "MyTestCollection"); Assert.AreEqual(y.CollectionName, "MyTestCollection"); Assert.IsInstanceOfType(y.GetById("xyz"), typeof(CustomIDEntityCustomCollection)); y.Delete("xyz"); Assert.AreEqual(0, y.Count()); }