public void Enumerate() { var db = new MemoryDatabase <string, int>(); var kt = new MockTransformer(); var vt = new MockTransformer(); var tdb = new TransformDatabase <string, int, int, string> ( db: db, keyTransformer: new ReverseTransformer <string, int>(kt), valueTransformer: vt ); tdb.InsertRange(new KeyValuePair <int, string>[] { new KeyValuePair <int, string>(1, "a"), new KeyValuePair <int, string>(2, "b"), new KeyValuePair <int, string>(3, "c"), }); tdb.EnumerateAggressively(3) .Should() .BeEquivalentTo(new KeyValuePair <int, string>[] { new KeyValuePair <int, string>(1, "a"), new KeyValuePair <int, string>(2, "b"), new KeyValuePair <int, string>(3, "c"), }); }
public GetFreeAppointmentByDateTests() { this.db = new KTasevaDbContext(MemoryDatabase.OptionBuilder()); var reCAPTCHAService = new Mock <IReCAPTCHAService>().Object; this.appointmentService = new AppointmentService(db, reCAPTCHAService); }
public async Task Test_GetKey() { Slice key; Slice value; using (var db = MemoryDatabase.CreateNew("DB")) { using (var tr = db.BeginTransaction(this.Cancellation)) { tr.Set(db.Pack(0), Slice.FromString("first")); tr.Set(db.Pack(10), Slice.FromString("ten")); tr.Set(db.Pack(20), Slice.FromString("ten ten")); tr.Set(db.Pack(42), Slice.FromString("narf!")); tr.Set(db.Pack(100), Slice.FromString("a hundred missipis")); await tr.CommitAsync(); } db.Debug_Dump(); using (var tr = db.BeginTransaction(this.Cancellation)) { value = await tr.GetAsync(db.Pack(42)); Console.WriteLine(value); Assert.That(value.ToString(), Is.EqualTo("narf!")); key = await tr.GetKeyAsync(FdbKeySelector.FirstGreaterOrEqual(db.Pack(42))); Assert.That(key, Is.EqualTo(db.Pack(42))); key = await tr.GetKeyAsync(FdbKeySelector.FirstGreaterThan(db.Pack(42))); Assert.That(key, Is.EqualTo(db.Pack(100))); key = await tr.GetKeyAsync(FdbKeySelector.LastLessOrEqual(db.Pack(42))); Assert.That(key, Is.EqualTo(db.Pack(42))); key = await tr.GetKeyAsync(FdbKeySelector.LastLessThan(db.Pack(42))); Assert.That(key, Is.EqualTo(db.Pack(20))); var keys = await tr.GetKeysAsync(new[] { FdbKeySelector.FirstGreaterOrEqual(db.Pack(42)), FdbKeySelector.FirstGreaterThan(db.Pack(42)), FdbKeySelector.LastLessOrEqual(db.Pack(42)), FdbKeySelector.LastLessThan(db.Pack(42)) }); Assert.That(keys.Length, Is.EqualTo(4)); Assert.That(keys[0], Is.EqualTo(db.Pack(42))); Assert.That(keys[1], Is.EqualTo(db.Pack(100))); Assert.That(keys[2], Is.EqualTo(db.Pack(42))); Assert.That(keys[3], Is.EqualTo(db.Pack(20))); await tr.CommitAsync(); } } }
public async Task Test_CommittedVersion_On_ReadOnly_Transactions() { //note: until CommitAsync() is called, the value of the committed version is unspecified, but current implementation returns -1 using (var db = MemoryDatabase.CreateNew("DB")) { var location = db.Keys; using (var tr = db.BeginTransaction(this.Cancellation)) { long ver = tr.GetCommittedVersion(); Assert.That(ver, Is.EqualTo(-1), "Initial committed version"); var _ = await tr.GetAsync(location.Encode("foo")); // until the transction commits, the committed version will stay -1 ver = tr.GetCommittedVersion(); Assert.That(ver, Is.EqualTo(-1), "Committed version after a single read"); // committing a read only transaction await tr.CommitAsync(); ver = tr.GetCommittedVersion(); Assert.That(ver, Is.EqualTo(-1), "Read-only comiitted transaction have a committed version of -1"); } db.Debug_Dump(); } }
/// <summary> /// login to account /// </summary> /// <param name="_name">username</param> /// <param name="_password">password</param> /// <param name="_autologin">autologin</param> /// <param name="_callback">on login callback</param> /// <returns></returns> public static bool login(string _name, string _password, bool _autologin, Action _callback) { if (MemoryDatabase.exist() && MemoryDatabase.database.CheckTableExistence("users")) { if (_autologin) { MainConfig.GetGroup("account").GetEntry("autologin").SetValue("1"); MainConfig.GetGroup("account").GetEntry("name").SetValue(_name); MainConfig.GetGroup("account").GetEntry("password").SetValue(_password); MainConfig.Save(); } string compactData = MemoryDatabase.database.GetDataFromTableFilter("users", "name='" + _name + "' && password='******'"); string[] data = compactData.Split(','); id = int.Parse(data[0]); name = Regex.Replace(data[1], @"\s+", ""); score = new Score() { wins = int.Parse(data[3]), losses = int.Parse(data[4]) }; isActivate = true; _callback?.Invoke(); return(true); } return(false); }
protected override void OnStop() { base.OnStop(); database.Stop(); database = null; }
public void CanUpdate() { // Arrange var db = new MemoryDatabase(); var productToInsert1 = new Product(); db.Insert<Product>(productToInsert1); var productToInsert2 = new Product(); db.Insert<Product>(productToInsert2); var productToInsert3 = new Product(); db.Insert<Product>(productToInsert3); // Get original var originalProduct = db.Select<Product>().Where(p=>p.Id == 2).Select(p => p).FirstOrDefault(); // Create modified var modifiedProduct = new Product(); modifiedProduct.Name = "Modified"; // Update db.Update<Product>(originalProduct, modifiedProduct); // Get original originalProduct = db.Select<Product>().Where(p => p.Id == 2).Select(p => p).FirstOrDefault(); // Assert Assert.AreEqual("Modified", originalProduct.Name); }
protected override void OnStart() { database = new MemoryDatabase(1024); database.Start(); SetBlockDatabase(database); }
public async Task Test_Atomic() { using (var db = MemoryDatabase.CreateNew("DB")) { var location = db.Keys; var key1 = location.Encode(1); var key2 = location.Encode(2); var key16 = location.Encode(16); for (int i = 0; i < 10; i++) { using (var tr = db.BeginTransaction(this.Cancellation)) { tr.AtomicAdd(key1, Slice.FromFixed64(1)); tr.AtomicAdd(key2, Slice.FromFixed64(2)); tr.AtomicAdd(key16, Slice.FromFixed64(16)); await tr.CommitAsync(); } } db.Debug_Dump(); // Collect memory Trace.WriteLine("### GARBAGE COLLECT! ###"); db.Collect(); db.Debug_Dump(); } }
// Using async Task Main() requires adding <LangVersion>latest</LangVersion> to .csproj file static async Task Main(string[] args) { const int port = 8000; var wwwPath = args.Length > 0 ? args[0] : "../../../www"; using var context = new EmbedIOContext($"http://+:{port}/", wwwPath); // Create a MemoryDatabase (no persistence, limited features) var database = new MemoryDatabase(); await database.CreateFromSqlAsync(@"CREATE TABLE message ( id INT NOT NULL AUTO_INCREMENT, text VARCHAR(40) NOT NULL, PRIMARY KEY (id) );"); // Listen for API requests context.WebApi.OnPost("/api/message/insert", async(req, res) => { var text = await req.ParseAsJsonAsync <dynamic>(); await database.InsertAndCommitAsync <long>("message", new { text }); }); // Listen for subscribe requests... // - The handler must return an IDisposable object (gets disposed when the channel is unsubscribed) // - The handler can push data to the client by calling channel.Queue() context.SubscriptionApi.OnSubscribe("messages", (vars, channel) => { return(database.CreateAndStartDynamicViewAsync("message", dataEventTransaction => channel.Queue(dataEventTransaction))); }); context.Start(); Console.ReadLine(); }
public async Task TestDynamic() { var database = new MemoryDatabase(); await database.CreateFromResourceFileAsync(Assembly.GetExecutingAssembly(), "Butterfly.Db.Test.butterfly_db_test.sql"); await DynamicUnitTest.TestDatabase(database); }
static void Main(string[] args) { IDatabase db = null; if (false && File.Exists(persistedDbPath)) { db = MemoryDatabase.OpenDatabase(persistedDbPath); } else { db = MemoryDatabase.CreateNewDatabase("root"); } DatabaseManager manager = new DatabaseManager(); manager.Mount("/", db); manager.Mount("/Volumes/Host", new HostDatabase(".", new KeyValuePair <string, ILoadableFactory>("appxml", new XmlLoadableFactory()), new KeyValuePair <string, ILoadableFactory>("libxml", new XmlLoadableFactory()), new KeyValuePair <string, ILoadableFactory>("xml", new XmlLoadableFactory()), new KeyValuePair <string, ILoadableFactory>("ipkg", new XmlLoadableFactory()) )); KernelStartup.Execute(manager, args); // persist the database MemoryDatabase.PersistToStream(persistedDbPath, db as MemoryDatabase); Environment.Exit(0); }
public ItemDataModel(Item item, bool hasTracking) : this() { this.item = item; index = item.Index; isTemporary = item.IsTemporary; data = MemoryDatabase.GetItemData(item); dataSource = MemoryDatabase.GetItemData(item); module = item.Module; _parentId = item.ParentId; propertyName = item.PropertyName; _siteId = item.SiteId; CreateDate = item.CreateDate; UpdateDate = item.UpdateDate; Id = item.Id; State = item.State; IsLoadedFromDatabase = true; if (item.Tags != null) { //Tags = item.Tags; //Tags.CollectionChanged -= tags_CollectionChanged; foreach (var itemTag in item.Tags) { Tags.Add(itemTag); } } HasTracking = hasTracking; }
public LecturesServiceGetVideoByLectureIdTests() { AutoMapperConfig.RegisterMappings(typeof(ErrorViewModel).GetTypeInfo().Assembly); this.db = new CoursesP2PDbContext(MemoryDatabase.OptionBuilder()); this.lecturesService = new LecturesService(this.db); }
public TransformerDatabaseTests() { _memoryDatabase = new MemoryDatabase <string, int>(); _keyTransformer = new MockTransformer(); _valueTransformer = new MockTransformer(); _transformDatabase = new TransformDatabase <string, int, int, string> ( db: _memoryDatabase, keyTransformer: _keyTransformer.Reverse(), valueTransformer: _valueTransformer ); _values = new[] { KeyValuePair.Create(1, "a"), KeyValuePair.Create(2, "b"), KeyValuePair.Create(3, "c"), }; _expectValues = _values .Select ( x => KeyValuePair.Create ( _keyTransformer.TransformPre(x.Key), _valueTransformer.TransformPost(x.Value) ) ) .ToArray(); }
public async Task Test_Use_Simple_Layer() { using (var db = MemoryDatabase.CreateNew("FOO")) { var location = db.GlobalSpace; var map = new FdbMap <int, string>("Foos", db.GlobalSpace.Partition.ByKey("Foos"), KeyValueEncoders.Values.StringEncoder); var index = new FdbIndex <int, string>("Foos.ByColor", db.GlobalSpace.Partition.ByKey("Foos", "Color")); using (var tr = db.BeginTransaction(this.Cancellation)) { map.Set(tr, 3, @"{ ""name"": ""Juliet"", ""color"": ""red"" }"); map.Set(tr, 2, @"{ ""name"": ""Joey"", ""color"": ""blue"" }"); map.Set(tr, 1, @"{ ""name"": ""Bob"", ""color"": ""red"" }"); index.Add(tr, 3, "red"); index.Add(tr, 2, "blue"); index.Add(tr, 1, "red"); await tr.CommitAsync(); } db.Debug_Dump(true); //// Collect memory //Trace.WriteLine("### GARBAGE COLLECT! ###"); //db.Collect(); //db.Debug_Dump(); } }
// Post public JsonMarkerInfoReply MarkerInfo(string id, int sendid) { var sw = new Stopwatch(); sw.Start(); var uid = int.Parse(id); var marker = MemoryDatabase.GetPoints().Data.SingleOrDefault(i => i.I == uid); if (marker == null) { return(new JsonMarkerInfoReply { Id = id, Content = "Marker could not be found", Rid = sendid, Msec = Sw(sw) }); } var reply = new JsonMarkerInfoReply { Rid = sendid, }; reply.BuildContent(marker); reply.Msec = Sw(sw); return(reply); }
public async Task Test_CommittedVersion_On_Write_Transactions() { //note: until CommitAsync() is called, the value of the committed version is unspecified, but current implementation returns -1 using (var db = MemoryDatabase.CreateNew("DB")) { var location = db.Keys; using (var tr = db.BeginTransaction(this.Cancellation)) { // take the read version (to compare with the committed version below) long readVersion = await tr.GetReadVersionAsync(); long ver = tr.GetCommittedVersion(); Assert.That(ver, Is.EqualTo(-1), "Initial committed version"); tr.Set(location.Encode("foo"), Slice.FromString("bar")); // until the transction commits, the committed version should still be -1 ver = tr.GetCommittedVersion(); Assert.That(ver, Is.EqualTo(-1), "Committed version after a single write"); // committing a read only transaction await tr.CommitAsync(); ver = tr.GetCommittedVersion(); Assert.That(ver, Is.GreaterThanOrEqualTo(readVersion), "Committed version of write transaction should be >= the read version"); } db.Debug_Dump(); } }
public async Task Test_Compare_Implementations() { for (int mode = 1; mode <= 6; mode++) { Console.WriteLine("#### SCENARIO " + mode + " ####"); using (var db = await Fdb.OpenAsync(this.Cancellation)) { using (var tr = db.BeginTransaction(this.Cancellation)) { await tr.GetReadVersionAsync(); switch (mode) { case 1: await Scenario1(tr); break; case 2: await Scenario2(tr); break; case 3: await Scenario3(tr); break; case 4: await Scenario4(tr); break; case 5: await Scenario5(tr); break; case 6: await Scenario6(tr); break; } await tr.CommitAsync(); } } using (var db = MemoryDatabase.CreateNew("DB")) { using (var tr = db.BeginTransaction(FdbTransactionMode.Default, this.Cancellation)) { await tr.GetReadVersionAsync(); switch (mode) { case 1: await Scenario1(tr); break; case 2: await Scenario2(tr); break; case 3: await Scenario3(tr); break; case 4: await Scenario4(tr); break; case 5: await Scenario5(tr); break; case 6: await Scenario6(tr); break; } await tr.CommitAsync(); } db.Debug_Dump(); } } }
public CoursesServiceDetailsTests() { AutoMapperConfig.RegisterMappings(typeof(ErrorViewModel).GetTypeInfo().Assembly); this.db = new CoursesP2PDbContext(MemoryDatabase.OptionBuilder()); this.coursesService = new CoursesService(this.db); }
private void SearchOperationsByVehicleId(MemoryDatabase imd, string vehicleIdFilter) { this.trace.Write(TraceLevel.Info, $"SEARCHING FOR VEHICLE {vehicleIdFilter} OPERATIONS"); IMT_Operations operationsTable = imd.GetTable(MemoryDatabaseTables.Operations) as IMT_Operations; IEnumerable <Operations> byVehicle = operationsTable.GetVehicleOperations(vehicleIdFilter); this.trace.Write(TraceLevel.Info, $"VEHICLE {vehicleIdFilter} HAS {(byVehicle as IList<Operations>).Count} OPERATIONS"); }
/// <summary> /// Step 1: /// Use a new connection to create the only table the application uses. /// But before we can do this, we need to clear all internal data (table, views, etc..) /// After this we can create the table. /// Step 2: /// Store a connection to the internal database structure. This is not a required step. /// But waste not, want not. /// </summary> public WebTestBuilder() { var connection = (MemoryDbConnection) new MemoryDbConnectionFactory( ).Create( ); Database = connection.GetMemoryDatabase( ); Database.Clear( ); connection.Execute(_SqlCreateTable); }
public CoursesContollerCategoryTests() { this.db = new CoursesP2PDbContext(MemoryDatabase.OptionBuilder()); this.userManager = UserManagerMock.UserManagerMockTest(); this.coursesService = new CoursesService(db); this.coursesController = new CoursesController(coursesService, reviewService, userManager, null, null); }
public void Works() { var mdb = new MemoryDatabase <string, int>(); mdb.InsertRange(new KeyValuePair <string, int>[] { new KeyValuePair <string, int>("a", 1), new KeyValuePair <string, int>("b", 2), new KeyValuePair <string, int>("c", 3), }); mdb.Keys() .Should() .BeEquivalentTo ( new[] { "a", "b", "c" } ); mdb.ValuesAggressive() .Should() .BeEquivalentTo ( new[] { 1, 2, 3 } ); mdb.InsertRange(new KeyValuePair <string, int>[] { new KeyValuePair <string, int>("a", 1), new KeyValuePair <string, int>("b", 2), new KeyValuePair <string, int>("c", 3), }); mdb.Keys() .Should() .BeEquivalentTo ( new[] { "a", "b", "c", "a", "b", "c" } ); mdb.ValuesAggressive() .Should() .BeEquivalentTo ( new[] { 1, 2, 3, 1, 2, 3 } ); }
public void Deserialization() { var transport = DataGenerator.CreateTransportDatabase(); var json = transport.ToJson(); File.WriteAllText("database.json", json); var transportDeserialized = MemoryDatabase.FromJson(json); var json2 = transportDeserialized.ToJson(); Assert.IsNotNull(transportDeserialized); Assert.AreEqual(transport.Sets.Count, transportDeserialized.Sets.Count); Assert.AreEqual(transport.Name, transportDeserialized.Name); foreach (var set in transport.Sets) { var setDeserialized = transportDeserialized.Sets.Single(x => x.Identifier == set.Identifier); Assert.AreEqual(set.Description, setDeserialized.Description); Assert.AreEqual(set.Dimension, setDeserialized.Dimension); Assert.AreEqual(set.Elements.Count, setDeserialized.Elements.Count); foreach (var element in set.Elements) { Assert.IsTrue(setDeserialized.Elements.Contains(element)); } } Assert.AreEqual(transport.Parameters.Count, transportDeserialized.Parameters.Count); foreach (var parameter in transport.Parameters) { var paramterDeserialized = transportDeserialized.Parameters.Single(x => x.Identifier == parameter.Identifier); Assert.AreEqual(parameter.Description, paramterDeserialized.Description); Assert.AreEqual(parameter.Dimension, paramterDeserialized.Dimension); Assert.AreEqual(parameter.Records.Count, paramterDeserialized.Records.Count); foreach (var record in parameter.Records) { Assert.AreEqual(record.Value, paramterDeserialized.Records[record.Key]); } } Assert.AreEqual(transport.Variables.Count, transportDeserialized.Variables.Count); foreach (var variable in transport.Variables) { var variableDeserialized = transportDeserialized.Variables.Single(x => x.Identifier == variable.Identifier); Assert.AreEqual(variable.Description, variableDeserialized.Description); Assert.AreEqual(variable.Dimension, variableDeserialized.Dimension); Assert.AreEqual(variable.Records.Count, variableDeserialized.Records.Count); Assert.AreEqual(variable.VariableType, variableDeserialized.VariableType); foreach (var record in variable.Records) { Assert.AreEqual(record.Value.Level, variableDeserialized.Records[record.Key].Level); Assert.AreEqual(record.Value.UpperBound, variableDeserialized.Records[record.Key].UpperBound); Assert.AreEqual(record.Value.LowerBound, variableDeserialized.Records[record.Key].LowerBound); Assert.AreEqual(record.Value.Scale, variableDeserialized.Records[record.Key].Scale); Assert.AreEqual(record.Value.Marginal, variableDeserialized.Records[record.Key].Marginal); } } Assert.AreEqual(json, json2); }
public void GenericTools_Data_MemoryDatabase_int() { var db = new MemoryDatabase <int>(); db.Add(3); db.Add(7); db.Add(5); MakeSure.That(db.GetAll().Sum(i => i)).Is(15); }
private void CreateTables(MemoryDatabase db) { db.ExecuteCommand(@" CREATE TABLE IF NOT EXISTS Employee ( [Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [Name] NVARCHAR(64) NOT NULL )"); Assert.IsTrue(db.ExecuteScalar <int>("SELECT count(*) from [Employee]") == 0); }
public void Test_Create_Complex_Database() { var db = new MemoryDatabase(); db.Setup(); //CreateComplexDatabaseSchema(db); CreateComplexDatabaseTables(db); }
public void TestMethod1() { var db = new MemoryDatabase(); db.Setup(); CreateTables(db.OpenDbConnection()); Assert.IsTrue(Test(db.OpenDbConnection())); Assert.IsTrue(TestCount <Employee>(db.OpenDbConnection(), 0)); //Assert.IsTrue(TestCount<Customer>(db.OpenDbConnection(), 0)); }
public void AfterFirstInsertIdIs1() { // Arrange var db = new MemoryDatabase(); var productToInsert = new Product(); // Act db.Insert<Product>(productToInsert); // Assert Assert.AreEqual(1, productToInsert.Id); }
private void SearchGroup(MemoryDatabase imd, long beasainGroup) { IMT_Groups groupsTable = imd.GetTable(MemoryDatabaseTables.Groups) as IMT_Groups; this.trace.Write(TraceLevel.Info, $"SEARCHING FOR GROUP {beasainGroup} "); string descripcion = groupsTable.GetGroupDesc(beasainGroup); long tipo = groupsTable.GetGroupType(beasainGroup); long related = groupsTable.GetGroupRelated(beasainGroup); this.trace.Write(TraceLevel.Info, $"GROUP {beasainGroup} \\t{descripcion} \\t{tipo} \\t{related}"); }
public static void MapItemToItemDataModel(Item item, ItemDataModel itemDataModel) { itemDataModel.Index = item.Index; itemDataModel.IsTemporary = item.IsTemporary; itemDataModel.Data = MemoryDatabase.GetItemData(item); itemDataModel.Module = item.Module; itemDataModel.ParentId = item.ParentId; itemDataModel.PropertyName = item.PropertyName; itemDataModel.SiteId = item.SiteId; itemDataModel.Id = item.Id; itemDataModel.State = item.State; }
public MemoryRepositorySimpleTests() { _database = new MemoryDatabase(); var databaseProvider = Substitute.For<IMemoryDatabaseProvider>(); databaseProvider.Database.Returns(_database); _repository = new MemoryRepository<TestEntity>(databaseProvider); // Testing Insert by creating initial data _repository.Insert(new TestEntity("test1")); _repository.Insert(new TestEntity("test2")); _database.Set<TestEntity>().Count.ShouldBe(2); }
static void Main(string[] args) { var uriDatabase = new UriDatabase(); var errorDatabase = new MemoryDatabase<string, long>(); GenerateReport(uriDatabase.SoftDump(), errorDatabase.ToDictionary()); var feeder = new FeedStream<ThreadedWorker>(); feeder.Feed(args.Skip(1).Select(s => new Uri(s))); var requesters = new List<HttpRequestStream<ThreadedWorker>>(); for (int i = 0; i < int.Parse(args.ElementAt(0)); i++) { requesters.Add(new HttpRequestStream<ThreadedWorker>(uriDatabase)); } var funnel = new FunnelStream<ContentLoad, Uri, ThreadedWorker>(); var parser = new ParserStream<ThreadedWorker>(); feeder.ReturnFeed = parser; parser.ReturnFeed = funnel; requesters.ForEach(stream => stream.ReturnFeed = feeder); funnel.ReturnFeeds = requesters; feeder.OnError += (sender, eventArgs) => CollectError(errorDatabase, eventArgs.GetException()); parser.OnError += (sender, eventArgs) => CollectError(errorDatabase, eventArgs.GetException()); funnel.OnError += (sender, eventArgs) => CollectError(errorDatabase, eventArgs.GetException()); requesters.ForEach(stream => stream.OnError += (sender, eventArgs) => CollectError(errorDatabase, eventArgs.GetException())); parser.Start(); funnel.Start(); requesters.ForEach(stream => stream.Start()); feeder.Start(); var timer = new Timer(2000); timer.Elapsed += (sender, eventArgs) => { var dump = uriDatabase.SoftDump(); var errors = errorDatabase.ToDictionary(); GenerateReport(dump, errors); }; timer.Start(); Console.ReadLine(); }
public MemoryRepository_Simple_Tests() { _database = new MemoryDatabase(); var databaseProvider = Substitute.For<IMemoryDatabaseProvider<int, long>>(); databaseProvider.Database.Returns(_database); _repository = new MemoryRepository<MyEntity, int, long>(databaseProvider); //Testing Insert by creating initial data _repository.Insert(new MyEntity("test-1")); _repository.Insert(new MyEntity("test-2")); _database.Set<MyEntity>().Count.ShouldBe(2); }
/// <summary> /// Constructor. /// </summary> public MemoryDbUnitOfWork( IAbpMemoryDbModuleConfiguration configuration, MemoryDatabase memoryDatabase, IConnectionStringResolver connectionStringResolver, IUnitOfWorkFilterExecuter filterExecuter, IUnitOfWorkDefaultOptions defaultOptions) : base( connectionStringResolver, defaultOptions, filterExecuter) { _configuration = configuration; _memoryDatabase = memoryDatabase; }
public void CanDelete() { // Arrange var db = new MemoryDatabase(); var productToInsert1 = new Product(); db.Insert<Product>(productToInsert1); var productToInsert2 = new Product(); db.Insert<Product>(productToInsert2); var productToInsert3 = new Product(); db.Insert<Product>(productToInsert3); // Act db.Delete<Product>(productToInsert2); // Assert Assert.AreEqual(2, db.Select<Product>().Count()); }
public void InsertFirstListFirst() { // Arrange var db = new MemoryDatabase(); // Act var productToInsert1 = new Product(); db.Insert<Product>(productToInsert1); var productToInsert2 = new Product(); db.Insert<Product>(productToInsert2); var productToInsert3 = new Product(); db.Insert<Product>(productToInsert3); // Assert var firstProduct = db.Select<Product>().FirstOrDefault(); Assert.AreEqual(1, firstProduct.Id); }
public void InsertIncrementsId() { // Arrange var db = new MemoryDatabase(); // Act var productToInsert1 = new Product(); db.Insert<Product>(productToInsert1); var productToInsert2 = new Product(); db.Insert<Product>(productToInsert2); var productToInsert3 = new Product(); db.Insert<Product>(productToInsert3); // Assert Assert.AreEqual(1, productToInsert1.Id); Assert.AreEqual(2, productToInsert2.Id); Assert.AreEqual(3, productToInsert3.Id); }
public ItemsController() { database = new MemoryDatabase(); database.Add(new Item()); }
public ItemsController() { database = new MemoryDatabase(); }
public void Setup() { this.database = new MemoryDatabase(); }
/// <summary> /// Constructor. /// </summary> public MemoryDbUnitOfWork(IAbpMemoryDbModuleConfiguration configuration, MemoryDatabase memoryDatabase, IUnitOfWorkDefaultOptions defaultOptions) : base(defaultOptions) { _configuration = configuration; _memoryDatabase = memoryDatabase; }
/// <summary> /// Constructor. /// </summary> public MemoryDbUnitOfWork(MemoryDatabase memoryDatabase, IUnitOfWorkDefaultOptions defaultOptions) : base(defaultOptions) { _memoryDatabase = memoryDatabase; }
protected override void BeginUow() { Database = _memoryDatabase; }
static void CollectError(MemoryDatabase<string, long> collection, Exception e) { collection.AddOrUpdate(e.Message, 1, l => l + 1); }