Ejemplo n.º 1
0
        public ExpiringDataStore(IExpirationPolicy <TValue, TExpirationInfo, TScanInfo> expirationPolicy, IEqualityComparer <TKey> equalityComparer)
        {
            ArgumentUtility.CheckNotNull("expirationPolicy", expirationPolicy);
            ArgumentUtility.CheckNotNull("equalityComparer", equalityComparer);

            _innerDataStore   = new SimpleDataStore <TKey, Tuple <TValue, TExpirationInfo> > (equalityComparer);
            _expirationPolicy = expirationPolicy;
            _nextScanInfo     = _expirationPolicy.GetNextScanInfo();
        }
        public void Initialize_WithCustomEqualityComparer()
        {
            var dataStore = new SimpleDataStore <string, int?> (StringComparer.InvariantCultureIgnoreCase);

            dataStore.Add("a", 1);

            Assert.That(dataStore.ContainsKey("a"));
            Assert.That(dataStore.ContainsKey("A"));
        }
Ejemplo n.º 3
0
        public void DefaultKeyExample()
        {
            const int id = 6133;
            const string value = "norfen pls";

            var db = new SimpleDataStore("keyExamples");
            var input = new KeyExampleClass {Id = id, Value = value};
            db.Save(input);

            var result = db.Get<KeyExampleClass>(id);
            Assert.Equal(result.Value, value);
        }
Ejemplo n.º 4
0
        public App()
        {
            // set up the model
            var dataStore = new SimpleDataStore();

            this.RegisterServiceInstance <IDataStore>(dataStore);

            // set the start object
            var startApplicationObject = new StartApplicationObject();

            this.RegisterServiceInstance <IMvxStartNavigation>(startApplicationObject);
        }
Ejemplo n.º 5
0
        public App()
        {
            Cirrious.MvvmCross.Plugins.File.PluginLoader.Instance.EnsureLoaded();
            Cirrious.MvvmCross.Plugins.ResourceLoader.PluginLoader.Instance.EnsureLoaded();

            // set up the model
            var dataStore = new SimpleDataStore();

            Mvx.RegisterSingleton <IDataStore>(dataStore);

            // set the start object
            RegisterAppStart <CustomerListViewModel>();
        }
Ejemplo n.º 6
0
        public void NonIntegerKeyNoConfiguration()
        {
            var id = Guid.NewGuid();
            const string value = "dat not candel in yuor pokit";

            var db = new SimpleDataStore("keyExamples");

            var input = new GuidKeyExampleClass {Id = id, Value = value};
            db.Save(input);

            var result = db.Get<GuidKeyExampleClass>(id);
            Assert.Equal(result.Value, value);
        }
Ejemplo n.º 7
0
        public void OverrideKeyExample()
        {
            const int id = 164;
            const int registrationNumber = 171339811;
            const string value = "acualy is beef";

            var db = new SimpleDataStore("keyExamples");
            db.Configure<KeyExampleClass>("keyExample1", "RegistrationNumber");

            var input = new KeyExampleClass {Id = id, RegistrationNumber = registrationNumber, Value = value};
            db.Save(input);

            var result = db.Get<KeyExampleClass>(id);
            Assert.Null(result);

            result = db.Get<KeyExampleClass>(registrationNumber);
            Assert.Equal(result.Value, value);
        }
Ejemplo n.º 8
0
 public Cache(IEqualityComparer <TKey> comparer)
 {
     _dataStore = new SimpleDataStore <TKey, TValue> (comparer);
 }
 public void SetUp()
 {
     _store = new SimpleDataStore <string, int?>();
     _store.Add("a", 1);
     _store.Add("b", 2);
 }