Exemplo n.º 1
0
        public void GetCredentials_WithNullCredentials_ThrowsOnGetCredentials()
        {
            // Arrange
            var unitUnderTest = new UserContextSettings(null, null, null, Default.Logon, false);

            // Act
            Action act = () => unitUnderTest.GetCredentials();

            // Assert
            Assert.Throws <ArgumentException>(act);
        }
Exemplo n.º 2
0
        public void GetCredentials_WithValidStrings_ReturnsUserCredentials()
        {
            // Arrange
            var unitUnderTest = new UserContextSettings("hello", "world", Default.Logon, false);

            // Act
            var credentials = unitUnderTest.GetCredentials();

            // Assert
            Assert.IsAssignableFrom <UserCredentials>(credentials);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Override base class to customise test display name to include username
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            var userContextTestAttributes = TestMethod.Method.GetCustomAttributes(typeof(IUserContextTest)).First();

            _userContext = userContextTestAttributes.GetNamedArgument <UserContextSettings>(nameof(UserTheoryAttribute.UserContext));

            if (_userContext.DisplayNameOnTest)
            {
                DisplayName += $"_(user: {_userContext?.DisplayName})";
            }
        }
 /// <summary>
 /// Initialises a new instance of the <see cref="UserContextTestRunner"/> class.
 /// </summary>
 /// <param name="test">The test that this invocation belongs to.</param>
 /// <param name="messageBus">The message bus to report run status to.</param>
 /// <param name="testClass">The test class that the test method belongs to.</param>
 /// <param name="constructorArguments">The arguments to be passed to the test class constructor.</param>
 /// <param name="testMethod">The test method that will be invoked.</param>
 /// <param name="testMethodArguments">The arguments to be passed to the test method.</param>
 /// <param name="skipReason">The skip reason, if the test is to be skipped.</param>
 /// <param name="beforeAfterAttributes">The list of <see cref="BeforeAfterTestAttribute"/>s for this test.</param>
 /// <param name="exceptionAggregator">The exception aggregator used to run code and collect exceptions.</param>
 /// <param name="cancellationTokenSource">The task cancellation token source, used to cancel the test run.</param>
 /// <param name="userContext">The user context settings for impersonation</param>
 public UserContextTestRunner(XunitTest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, IReadOnlyList <BeforeAfterTestAttribute> beforeAfterAttributes, ExceptionAggregator exceptionAggregator, CancellationTokenSource cancellationTokenSource, UserContextSettings userContext)
     : base(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, exceptionAggregator, cancellationTokenSource)
 {
     _userContext = userContext;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initialises a new instance of <see cref="UserContextTestCaseRunner"/>
 /// </summary>
 /// <param name="testCase"></param>
 /// <param name="displayName"></param>
 /// <param name="skipReason"></param>
 /// <param name="constructorArguments"></param>
 /// <param name="testMethodArguments"></param>
 /// <param name="messageBus"></param>
 /// <param name="aggregator"></param>
 /// <param name="cancellationTokenSource"></param>
 /// <param name="userContext"></param>
 public UserContextTestCaseRunner(IXunitTestCase testCase, string displayName, string skipReason, object[] constructorArguments, object[] testMethodArguments, IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, UserContextSettings userContext)
     : base(testCase, displayName, skipReason, constructorArguments, testMethodArguments, messageBus, aggregator, cancellationTokenSource)
 {
     _userContext = userContext;
 }