Exemple #1
0
        public void ContextHolder_SetAndGetData()
        {
            var contextHolder = ContextHolderMock.Create();
            var name          = "contextHolderTest";
            var contextDummy  = new ContextDummy
            {
                Id   = 12,
                Name = "Test"
            };

            contextHolder.SetData(name, contextDummy);
            var contextFromHolder = (ContextDummy)contextHolder.GetData(name);

            Assert.AreEqual(contextDummy, contextFromHolder);
        }
Exemple #2
0
        public void ContextHolder_SetAndGetData_MultiThread()
        {
            var contextHolder = ContextHolderMock.Create();
            var name          = "contextHolderTest";
            var contextDummy  = new ContextDummy
            {
                Id   = 12,
                Name = "Test"
            };

            contextHolder.SetData(name, contextDummy);
            var contextFromHolder = Task.Factory.StartNew(() =>
            {
                return((ContextDummy)contextHolder.GetData(name));
            }).Result;

            Assert.AreEqual(contextDummy, contextFromHolder);
        }