public void TestExceptionSerialization()
        {
            ShardLocation sl1 = new ShardLocation("dataSource1", "database1");
            ShardLocation sl2 = new ShardLocation("dataSource2", "database2");

            MultiShardException innerEx1 = new MultiShardException(sl1);
            MultiShardException innerEx2 = new MultiShardException(sl2);

            List <Exception> exList = new List <Exception>();

            exList.Add(innerEx1);
            exList.Add(innerEx2);

            MultiShardAggregateException aggEx = new MultiShardAggregateException(exList);

            MultiShardException deserialized1 = CommonTestUtils.SerializeDeserialize(innerEx1);

            CompareForEquality(innerEx1, deserialized1);

            MultiShardException deserialized2 = CommonTestUtils.SerializeDeserialize(innerEx2);

            CompareForEquality(innerEx2, deserialized2);

            MultiShardAggregateException deserialized3 = CommonTestUtils.SerializeDeserialize(aggEx);

            CompareForEquality(aggEx, deserialized3);
        }
Пример #2
0
 public void Dispose()
 {
     if (Invalid)
     {
         return;
     }
     CommonTestUtils.WriteMessageLine($"UserContextSwitch: Reverting user '{Switcher.GetUuIdFn()}' with '{OldUserUUid}'");
     Switcher.SetUuIdFn(OldUserUUid);
 }
        public void TestSchemaInfoExceptionSerializability()
        {
            SchemaInfoException ex           = new SchemaInfoException(SchemaInfoErrorCode.SchemaInfoNameConflict, "message");
            SchemaInfoException deserialized = CommonTestUtils.SerializeDeserialize(ex);

            // Validate
            Assert.AreEqual(ex.ErrorCode, deserialized.ErrorCode, "ErrorCode");
            Assert.AreEqual(ex.ToString(), deserialized.ToString(), "ToString()");
        }
Пример #4
0
        public void Create_ShouldReturnATextAreaWindow()
        {
            CommonTestUtils.RunInStaThread(() =>
            {
                var textAreaWindow = _textAreaWindowFactory.Create();

                textAreaWindow.Should().BeOfType <EditResponseWindow>();
            });
        }
Пример #5
0
        public void Create_ShouldReturnAlwaysANewInstance()
        {
            CommonTestUtils.RunInStaThread(() =>
            {
                var textAreaWindow1 = _textAreaWindowFactory.Create();
                var textAreaWindow2 = _textAreaWindowFactory.Create();

                textAreaWindow1.Should().NotBe(textAreaWindow2);
            });
        }
Пример #6
0
        public void TestShardMapManagerExceptionSerializability()
        {
            var errorCategory = ShardManagementErrorCategory.RangeShardMap;
            var errorCode     = ShardManagementErrorCode.ShardMapDoesNotExist;

            ShardManagementException ex           = new ShardManagementException(errorCategory, errorCode, "Testing");
            ShardManagementException deserialized = CommonTestUtils.SerializeDeserialize(ex);

            // Validate
            Assert.AreEqual(ex.ErrorCode, deserialized.ErrorCode, "ErrorCode");
            Assert.AreEqual(ex.ErrorCategory, deserialized.ErrorCategory, "ErrorCategory");
            Assert.AreEqual(ex.ToString(), deserialized.ToString(), "ToString()");
        }
Пример #7
0
 private void SetUUid(string uuid)
 {
     if (string.IsNullOrEmpty(uuid))
     {
         CommonTestUtils.WriteMessageLine("Empty UUID specified, not switching user.");
         Invalid = true;
     }
     else
     {
         CommonTestUtils.WriteMessageLine($"UserContextSwitch: Replacing user '{Switcher.GetUuIdFn()}' with '{uuid}'");
         OldUserUUid = Switcher.GetUuIdFn();
         Switcher.SetUuIdFn(uuid);
     }
 }
Пример #8
0
 /// <summary>
 /// Changes the current user's identity between a IsSecond organisation and a normal First organisation
 /// </summary>
 /// <param name="standardIdentityType"></param>
 /// <param name="switcher"></param>
 public AutoResetUserContext(CommonTestUtils.CustomerIdentityType standardIdentityType, ICredentialSwitcher switcher)
 {
     Switcher         = switcher;
     IsSecondCustomer = standardIdentityType == CommonTestUtils.CustomerIdentityType.CustomerType2;
     CommonTestUtils.SwitchTestUser(standardIdentityType, SetUUid, () => { CommonTestUtils.WriteMessageLine($"Impersonating {Switcher.GetUuIdFn()}"); });
 }