コード例 #1
0
            public void WhenStoreExistingKey_ThenReplacesKey()
            {
                var fakeKey = new FakeCryptoKey();
                var key     = new OAuthCryptoKey
                {
                    Id     = "fooid",
                    Bucket = "foo",
                    Handle = "bar",
                    Key    = new byte[]
                    {
                        0x01,
                        0x01
                    },
                    ExpiresUtc = DateTime.UtcNow,
                };

                this.storage.Setup(s => s.Find(It.IsAny <string>()))
                .Returns(new[]
                {
                    key
                });

                this.store.StoreKey("foo", "bar", fakeKey);

                this.storage.Verify(s => s.Delete("fooid"), Times.Once());
                this.storage.Verify(s => s.Add(It.Is <OAuthCryptoKey>(ack =>
                                                                      ack.Bucket == "foo" &&
                                                                      ack.Handle == "bar" &&
                                                                      ack.ExpiresUtc == DateTime.Today.ToUniversalTime())), Times.Once());
            }
コード例 #2
0
            public void WhenStoreKey_ThenAddsKey()
            {
                var fakeKey = new FakeCryptoKey();

                this.store.StoreKey("foo", "bar", fakeKey);

                this.storage.Verify(s => s.Add(It.Is <OAuthCryptoKey>(ack =>
                                                                      ack.Bucket == "foo" &&
                                                                      ack.Handle == "bar" &&
                                                                      ack.ExpiresUtc == DateTime.Today.ToUniversalTime())), Times.Once());
            }