private void TimerOnTick(object sender, EventArgs e) { if (!_resized) { Resize(this); _resized = true; } else { if (Actions.Count > 0) { var action = Actions.Dequeue(); try { action(DataGrid); } catch (XunitException ex) { Exception = ex; Stop(); } } else { Stop(); } } }
public void UnmatchedTypeThrows() { XunitException exception = Assert.Throws <IsTypeException>( () => Assert.IsType(typeof(InvalidCastException), new InvalidOperationException())); Assert.Equal("Assert.IsType() Failure", exception.UserMessage); }
public void MatchedTypeThrows() { XunitException exception = Assert.Throws <IsNotTypeException>( () => Assert.IsNotType <InvalidCastException>(new InvalidCastException())); Assert.Equal("Assert.IsNotType() Failure", exception.UserMessage); }
public FaliedAssertionException(XunitException inner) : base(inner.Message) { // for now - restore the stack trace trimmedStackTrace = inner.StackTrace; // trim off the non-test related frames from the stack trace // we really only want to show the top frame (at position 1) //trimmedStackTrace =new StackTrace(new StackTrace(inner,true).GetFrame(1)).ToString(); }
public void XunitException() { var ex = new XunitException("This is the message"); var result = ExceptionUtility.GetMessage(ex); Assert.Equal("This is the message", result); }
public void AggregateException() { var inner1 = new DivideByZeroException("inner #1"); var inner2 = new NotImplementedException("inner #2"); var inner3 = new XunitException("this is crazy"); var outer = new AggregateException(inner1, inner2, inner3); var result = ExceptionUtility.GetMessage(outer); Assert.Equal("System.AggregateException : One or more errors occurred." + Environment.NewLine + "---- System.DivideByZeroException : inner #1" + Environment.NewLine + "---- System.NotImplementedException : inner #2" + Environment.NewLine + "---- this is crazy", result); }
public async Task <HttpResponseMessage> PostAsync(string requestUri, Stream contentStream) { if (simulateNetworkFailure) { simulateNetworkFailure = false; return(new HttpResponseMessage(HttpStatusCode.ServiceUnavailable)); } // Make sure content stream doesn't contain BOM var head = new byte[3]; await contentStream.ReadAsync(head, 0, 3); if (head.SequenceEqual(System.Text.Encoding.UTF8.GetPreamble())) { var exception = new XunitException("Posted content stream should not contain UTF8 BOM"); exceptions.Enqueue(exception); throw exception; } contentStream.Position = 0; DefaultBatch batch; try { using var reader = new StreamReader(contentStream); batch = JsonConvert.DeserializeObject <DefaultBatch>(await reader.ReadToEndAsync()); } catch (Exception) { var exception = new XunitException($"{nameof(HttpClientMock)} assume log events are formatted using {nameof(NormalRenderedTextFormatter)}, and batches are formatted using {nameof(DefaultBatchFormatter)}"); exceptions.Enqueue(exception); throw exception; } batches.Enqueue(batch); return(new HttpResponseMessage { Content = new StreamContent(contentStream) }); }
public void DoActions(Func <DataGrid> createDataGrid, Action <Window> resize, Queue <Action <DataGrid> > actions) { _resized = false; Finished = false; Exception = null; Content = null; DataGrid = createDataGrid(); Resize = resize; Actions = actions; Content = DataGrid; _timer = new DispatcherTimer(); _timer.Tick += TimerOnTick; _timer.Interval = new TimeSpan(0, 0, 0, 1); _timer.Start(); }
public void PreservesUserMessage() { var ex = new XunitException("UserMessage"); Assert.Equal("UserMessage", ex.UserMessage); }
public void UserMessageIsTheMessage() { var ex = new XunitException("UserMessage"); Assert.Equal(ex.UserMessage, ex.Message); }
private async Task TestPipeInternalAsync(int bufferSize, int maxBlocks) { var pipe = new PipedStreamManager(new PipedStreamOptions() { BlockSize = bufferSize, MaxBlocks = maxBlocks }); XunitException assertFailedEx = null; var minNumberToSend = uint.MaxValue / 2; var maxNumberToSend = minNumberToSend + 5 * 1024; var readerTask = Task.Run(async() => { using (var reader = pipe.CreateReader()) { try { uint i = minNumberToSend; UInt32Converter converter = new UInt32Converter(0); byte[] buffer = new byte[4]; int read = 0; int position = 0; for (; i <= maxNumberToSend; i++) { read = await reader.ReadAsync(buffer, 0, 4); position += read; converter.ReadFromArray(buffer); Assert.True(read == 4, "read == 4"); Assert.True(converter.Value == i, "converter.Value == i"); } //test if it's the end. read = await reader.ReadAsync(buffer, 0, 4); Assert.True(read == 0, "read == 0"); Assert.True(reader.Position == position, "reader.Position == position"); } catch (XunitException failedEx) { assertFailedEx = failedEx; throw; } catch (Exception ex) { throw; } } }); await Task.Delay(1); var writerTask = Task.Run(async() => { using (var writer = pipe.CreateWriter(throwsFailedWrite: true)) { try { uint i = minNumberToSend; UInt32Converter converter = new UInt32Converter(0); byte[] buffer = new byte[4]; int position = 0; for (; i <= maxNumberToSend; i++) { converter.SetValue(i); converter.WriteToArray(buffer); await writer.WriteAsync(buffer, 0, 4); position += 4; } Assert.True(writer.Position == position, "writer.Position == position"); await writer.FlushAsync(); } catch (XunitException failedEx) { assertFailedEx = failedEx; throw; } catch (Exception ex) { throw; } } }); try { await readerTask; } catch (Exception ex) { if (assertFailedEx == null || assertFailedEx == ex) { throw; } } try { await writerTask; } catch (Exception ex) { if (assertFailedEx == null || assertFailedEx == ex) { throw; } } }
public AssertBarException(string barEntry, XunitException innerException) : base($"Failed assertion for BAR {barEntry}", innerException) { }
public WrappedXunitException(string userMessage, XunitException innerException) : base(userMessage, innerException) { }
public DescriptiveException(string userMessage, XunitException innerException) : base(userMessage, innerException) { }