public void AzureResourceBroker_ExtractParameters_WithMissingPermissions_ThrowsException()
        {
            // Setup
            TestResourceBroker broker = new TestResourceBroker();
            JToken parameters = this.GenerateTableJson();
            parameters["permissions"] = string.Empty;

            // Act
            this.ExpectException<HttpResponseException>(() => broker.ExtractParameters(parameters));
        }
        public void AzureResourceBroker_ExtractParameters_WithInvalidDate_ThrowsException()
        {
            // Setup
            TestResourceBroker broker = new TestResourceBroker();
            JToken parameters = this.GenerateTableJson();
            parameters["expiry"] = "asfasdf";

            // Act
            this.ExpectException<HttpResponseException>(() => broker.ExtractParameters(parameters));
        }
        public void AzureResourceBroker_ExtractParameters_WithInvalidDate_ThrowsException()
        {
            // Setup
            TestResourceBroker broker     = new TestResourceBroker();
            JToken             parameters = this.GenerateTableJson();

            parameters["expiry"] = "asfasdf";

            // Act
            this.ExpectException <HttpResponseException>(() => broker.ExtractParameters(parameters));
        }
        public void AzureResourceBroker_ExtractParameters_WithMissingPermissions_ThrowsException()
        {
            // Setup
            TestResourceBroker broker     = new TestResourceBroker();
            JToken             parameters = this.GenerateTableJson();

            parameters["permissions"] = string.Empty;

            // Act
            this.ExpectException <HttpResponseException>(() => broker.ExtractParameters(parameters));
        }
        public void AzureResourceBroker_ExtractParameters_ReturnsResourceParameters()
        {
            // Setup
            TestResourceBroker broker = new TestResourceBroker();

            // Act
            ResourceParameters parameters = broker.ExtractParameters(this.GenerateTableJson());

            // Assert
            Assert.AreEqual("table", parameters.Name);
            Assert.AreEqual(ResourcePermissions.ReadWrite, parameters.Permissions);
            Assert.IsTrue(parameters.Expiration > DateTime.UtcNow - TimeSpan.FromSeconds(1) && parameters.Expiration < DateTime.UtcNow + TimeSpan.FromSeconds(1));
        }
        public void AzureResourceBroker_ExtractParameters_ReturnsResourceParameters()
        {
            // Setup
            TestResourceBroker broker = new TestResourceBroker();

            // Act
            ResourceParameters parameters = broker.ExtractParameters(this.GenerateTableJson());

            // Assert
            Assert.AreEqual("table", parameters.Name);
            Assert.AreEqual(ResourcePermissions.ReadWrite, parameters.Permissions);
            Assert.IsTrue(parameters.Expiration > DateTime.UtcNow - TimeSpan.FromSeconds(1) && parameters.Expiration < DateTime.UtcNow + TimeSpan.FromSeconds(1));
        }
 public void AzureResourceBroker_ExtractParameters_WithNullJsonParameters_ThrowsArgumentException()
 {
     TestResourceBroker broker = new TestResourceBroker();
     this.ExpectException<ArgumentNullException>(() => broker.ExtractParameters((JToken)null));
 }
        public void AzureResourceBroker_ExtractParameters_WithNullJsonParameters_ThrowsArgumentException()
        {
            TestResourceBroker broker = new TestResourceBroker();

            this.ExpectException <ArgumentNullException>(() => broker.ExtractParameters((JToken)null));
        }