コード例 #1
0
        public void can_store()
        {
            var model = new SampleReadModelWithStringKey()
            {
                Id = "a"
            };

            _inmemoryCollection.Save(model);
            Assert.AreEqual(1, _inmemoryCollection.GetAll().Count());
        }
コード例 #2
0
        public void should_throw_if_duplicated_id()
        {
            var model = new SampleReadModelWithStringKey()
            {
                Id = "a"
            };

            _inmemoryCollection.Insert(model);

            var ex = Assert.Throws <DuplicatedElementException>(() => _inmemoryCollection.Insert(model));

            Assert.AreEqual("Duplicated element with id a", ex.Message);
        }
コード例 #3
0
        public void clear_should_remove_all_models()
        {
            var model = new SampleReadModelWithStringKey()
            {
                Id = "a"
            };

            _inmemoryCollection.Save(model);

            _inmemoryCollection.Clear();

            Assert.AreEqual(0, _inmemoryCollection.GetAll().Count());
        }
コード例 #4
0
        public void can_delete_by_id()
        {
            var model = new SampleReadModelWithStringKey()
            {
                Id = "a"
            };

            _inmemoryCollection.Save(model);

            _inmemoryCollection.Delete("a");

            Assert.AreEqual(0, _inmemoryCollection.GetAll().Count());
        }
コード例 #5
0
        public void can_store_and_retrieve_model()
        {
            var model = new SampleReadModelWithStringKey()
            {
                Id = "a"
            };

            _inmemoryCollection.Save(model);

            var loaded = _inmemoryCollection.GetById("a");

            Assert.AreSame(model, loaded);
            Assert.AreEqual(1, _inmemoryCollection.GetAll().Count());
        }