Пример #1
0
 public void ModuleAuthenticationWithTokenRefresh_Ctor_WrongArguments_Fail()
 {
     TestAssert.Throws <ArgumentNullException>(() => new TestImplementation(null, TestModuleId));
     TestAssert.Throws <ArgumentNullException>(() => new TestImplementation(TestDeviceId, null));
     TestAssert.Throws <ArgumentNullException>(() => new TestImplementation("   ", TestModuleId));
     TestAssert.Throws <ArgumentNullException>(() => new TestImplementation(TestDeviceId, "  "));
     TestAssert.Throws <ArgumentOutOfRangeException>(() => new TestImplementation(TestDeviceId, TestModuleId, -1, 10));
     TestAssert.Throws <ArgumentOutOfRangeException>(() => new TestImplementation(TestDeviceId, TestModuleId, 60, -1));
     TestAssert.Throws <ArgumentOutOfRangeException>(() => new TestImplementation(TestDeviceId, TestModuleId, 60, 101));
 }
Пример #2
0
        public void DisposingOwnedStreamTest()
        {
            // ownStream = true
            var ms  = new MemoryStream(Encoding.UTF8.GetBytes("Hello, World!"));
            var msg = new Message(ms, true);

            msg.Dispose();

            TestAssert.Throws <ObjectDisposedException>(() => ms.Write(Encoding.UTF8.GetBytes("howdy"), 0, 5));

            // ownStream = false
            ms  = new MemoryStream(Encoding.UTF8.GetBytes("Hello, World!"));
            msg = new Message(ms, false);
            msg.Dispose();

            ms.Write(Encoding.UTF8.GetBytes("howdy"), 0, 5);
        }
Пример #3
0
        public void DisposingOwnedStreamTest()
        {
            // SDK should dispose the stream.
            var ms  = new MemoryStream(Encoding.UTF8.GetBytes("Hello, World!"));
            var msg = new Message(ms, StreamDisposalResponsibility.Sdk);

            msg.Dispose();

            TestAssert.Throws <ObjectDisposedException>(() => ms.Write(Encoding.UTF8.GetBytes("howdy"), 0, 5));

            // The calling application will dispose the stream.
            ms  = new MemoryStream(Encoding.UTF8.GetBytes("Hello, World!"));
            msg = new Message(ms, StreamDisposalResponsibility.App);
            msg.Dispose();

            ms.Write(Encoding.UTF8.GetBytes("howdy"), 0, 5);
        }
Пример #4
0
        public void ConvertDeliveryAckTypeToStringInvalidValueFail()
        {
            Action action = () => Utils.ConvertDeliveryAckTypeToString((DeliveryAcknowledgement)100500);

            TestAssert.Throws <NotSupportedException>(action);
        }
Пример #5
0
        public void ConvertDeliveryAckTypeFromStringInvalidStringFail()
        {
            Action action = () => Utils.ConvertDeliveryAckTypeFromString("unknown");

            TestAssert.Throws <NotSupportedException>(action);
        }
Пример #6
0
        public void DeviceAuthenticationWithTokenRefresh_Populate_InvalidConnectionStringBuilder_Fail()
        {
            var refresher = new TestImplementation(TestDeviceId);

            TestAssert.Throws <ArgumentNullException>(() => refresher.Populate(null));
        }