Ejemplo n.º 1
0
        public void Sample()
        {
            NuclearStorage storage  = null;
            var            customer = new Customer()
            {
                Name    = "My first customer",
                Address = "The address"
            };

            storage.AddEntity("cust-123", customer);
            storage.UpdateEntity <Customer>("cust-123", c =>
            {
                c.Address = "Customer Moved";
            });

            var result = storage.GetEntity <Customer>("cust-123").Value;

            Console.WriteLine("{0}: {1}", result.Name, result.Address);
        }
            public void Consume(Message message)
            {
                _view.UpdateEnforcingNew(1, v => v.Value += 1);
                _storage.UpdateEntity <CustomDomainViewWithTypedKey>(1, t => t.Value += 1);

                var actual = _storage.GetEntity <CustomDomainViewWithTypedKey>(1).Convert(c => c.Value).GetValue(0);

                _sender.SendOne(new FinishMessage(), meb =>
                {
                    if (actual != 2)
                    {
                        meb.AddString("fail", "Expected 2 but got " + actual);
                    }
                    else
                    {
                        meb.AddString("finish");
                    }
                });
            }
Ejemplo n.º 3
0
        void VerifyNonAtomic(NuclearStorage storage)
        {
            storage.AddOrUpdateEntity(1, new Entity());
            storage.GetEntity <Entity>(1);
            storage.UpdateEntity <Entity>(1, e => e.Do());
            storage.TryDeleteEntity <Entity>(1);


            storage.AddOrUpdateSingleton(() => new Entity(), e => e.Do());
            storage.UpdateSingletonEnforcingNew <Entity>(e => e.Do());
            storage.GetSingleton <Entity>();
            storage.TryDeleteSingleton <Entity>();
            storage.UpdateSingleton <Entity>(e => e.Do());


            //storage.UpdateOrAddEntity<Entity>(1, e => e.Do());
            //storage.TryDelete<Entity>(1);

            //storage.SaveSingleton(new Entity());
            //storage.GetSingleton<Entity>();
            //storage.UpdateSingleton<Entity>(e => e.Do());
            //storage.TryDeleteSingleton<Entity>();
        }
Ejemplo n.º 4
0
 private static void AssertContents(NuclearStorage setup)
 {
     Assert.AreEqual("test", setup.GetEntity <string>(1).Value);
     Assert.AreEqual(1, setup.GetSingleton <int>().Value);
 }