public async Task Update_Menu_Profile_In_Mongo_Test() { if (!_context.AllowMongoDB) { Assert.True(true); return; } // Arrange DatabaseOptions databaseOptions = new DatabaseOptions { ConnectionString = _context.MongoDatabaseConenction.ConnectionString, ConnectionType = ConnectionType.MongoDB, Datasource = _context.MongoDatabaseConenction.DataSource }; IOptionsMonitor <DatabaseOptions> databaseOptionsMock = Mock.Of <IOptionsMonitor <DatabaseOptions> >(_ => _.CurrentValue == databaseOptions); AppMongoRepository appMongoRepository = new AppMongoRepository(new Core.Persistences.MongoConnection(databaseOptionsMock.CurrentValue)); // Act App app = new App { Id = DataUtil.GenerateUniqueId(), Name = "testapp1", DisplayName = "Test App" }; await appMongoRepository.AddAsync(app); List <Menu> menus = new List <Menu> { new Menu { Id = Guid.NewGuid().ToString(), DisplayName = "Core" } }; await appMongoRepository.UpdateMenuAsync(app.Id, menus); MenuProfile menuProfile = new MenuProfile { MenuIds = new List <string> { menus[0].Id }, Role = "Admin" }; await appMongoRepository.UpdateMenuProfileAsync(app.Id, menuProfile); appMongoRepository.Dispose(); // Assert Assert.True(true); }
public async Task Compare_App_In_Mongo_Test() { if (!_context.AllowMongoDB) { Assert.True(true); return; } // Arrange DatabaseOptions databaseOptions = new DatabaseOptions { ConnectionString = _context.MongoDatabaseConenction.ConnectionString, ConnectionType = ConnectionType.MongoDB, Datasource = _context.MongoDatabaseConenction.DataSource }; IOptionsMonitor <DatabaseOptions> databaseOptionsMock = Mock.Of <IOptionsMonitor <DatabaseOptions> >(_ => _.CurrentValue == databaseOptions); AppMongoRepository appMongoRepository = new AppMongoRepository(new Core.Persistences.MongoConnection(databaseOptionsMock.CurrentValue)); // Act App app = new App { Id = DataUtil.GenerateUniqueId(), Name = "testapp123456", DisplayName = "Test App" }; await appMongoRepository.AddAsync(app); List <Menu> menus = new List <Menu> { new Menu { Id = Guid.NewGuid().ToString(), DisplayName = "Core" } }; app.Menus = menus; ComparisonResult result = await appMongoRepository.Compare(app); appMongoRepository.Dispose(); // Assert Assert.True(result.Result.Properties.First(a => a.Name == "Menus").ComparedState == ComparedState.Changed); }