예제 #1
0
 public void ReadRead()
 {
     AddAccount("account1");
     AddAccount("account2");
     ExecuteConcurrently(ReadAccounts, ReadAccounts);
     AccountCollection.Count().Should(Be.EqualTo(2));
 }
예제 #2
0
 public void Write3Remove1()
 {
     AddAccount("account1");
     ExecuteConcurrently(ReadAccounts, () => AddAccount("account2"));
     ExecuteConcurrently(() => AddAccount("account3"), () => RemoveAccount("account2"));
     AccountCollection.Count().Should(Be.EqualTo(2));
 }
예제 #3
0
        public void WriteTwiceReadTwice()
        {
            int afterAccountAdded = 0;
            var account1Name      = new AccountName("account1");
            var account2Name      = new AccountName("account2");

            ExecuteConcurrently(() =>
            {
                AccountCollection.GetOrCreate(account1Name);
                AccountCollection.GetOrCreate(account2Name);
                Interlocked.Increment(ref afterAccountAdded);
            }, () =>
            {
                if (Interlocked.Increment(ref afterAccountAdded) == 2)
                {
                    AccountCollection.Count().Should(Be.EqualTo(2));
                }
            });
            AccountCollection.Count().Should(Be.EqualTo(2));
        }
예제 #4
0
 public void WriteWrite()
 {
     ExecuteConcurrently(() => AddAccount("account1"), () => AddAccount("account2"));
     AccountCollection.Count().Should(Be.EqualTo(2));
 }