private static void Write(Exception ex, string messageFormat, params object[] messageArgs) { var writer = new DefaultOutputWriter(Console.Write); writer.Write(messageFormat, messageArgs); writer.WriteLine(); using (writer.Indent()) { writer.Write(ex.Message); writer.WriteLine(); } }
public void Write_ShouldWriteEachFormattedItem([Frozen] Mock <IOutputSorter> outputSorterMock, [Frozen] Mock <IOutputFormatter> outputFormatterMock, [Frozen] Mock <IWriterStrategy> writerStrategyMock, IEnumerable <Tuple <OutputGroupModel, string> > data, DefaultOutputWriter sut) { // arrange var models = data.Select(d => d.Item1); outputSorterMock.Setup(m => m.Sort(models)).Returns(models); foreach (var item in data) { outputFormatterMock.Setup(m => m.FormatWarehouse(item.Item1)).Returns(item.Item2); } // act sut.Write(models); // assert foreach (var item in data) { writerStrategyMock.Verify(m => m.WriteLine(It.Is <string>(s => item.Item2.Equals(s))), Times.Once()); } }
public void Write_ShouldSortItems([Frozen] Mock <IOutputSorter> outputSorterMock, IEnumerable <OutputGroupModel> models, DefaultOutputWriter sut) { // act sut.Write(models); // assert outputSorterMock.Verify(m => m.Sort(It.Is <IEnumerable <OutputGroupModel> >(d => d == models)), Times.Once()); }
private static void WarnFailedToGetSomeTypes(Assembly assembly, ReflectionTypeLoadException ex) { var writer = new DefaultOutputWriter(Console.Write); Write( writer, ex, $"Warning: FakeItEasy failed to get some types from assembly '{assembly}' while scanning for extension points. Some IArgumentValueFormatters, IDummyFactories, and IFakeOptionsBuilders in that assembly might not be available."); using (writer.Indent()) { int notLoadedCount = ex.Types.Count(t => t == null); writer.Write($"{notLoadedCount} type(s) were not loaded for the following reasons:"); writer.WriteLine(); foreach (var loaderException in ex.LoaderExceptions) { writer.Write(" - "); writer.Write(loaderException.GetType()); writer.Write(": "); writer.Write(loaderException.Message); writer.WriteLine(); } } }
public void Write_ShouldFormatEachItem([Frozen] Mock <IOutputSorter> outputSorterMock, [Frozen] Mock <IOutputFormatter> outputFormatterMock, IEnumerable <OutputGroupModel> models, DefaultOutputWriter sut) { // arrange outputSorterMock.Setup(m => m.Sort(models)).Returns(models); // act sut.Write(models); // assert foreach (var outputGroupModel in models) { outputFormatterMock.Verify(m => m.FormatWarehouse(It.Is <OutputGroupModel>(d => d == outputGroupModel)), Times.Once()); } }
private static void Write(Exception ex, string messageFormat, params object[] messageArgs) { var writer = new DefaultOutputWriter(Console.Write); writer.Write(messageFormat, messageArgs); writer.WriteLine(); using (writer.Indent()) { writer.Write(ex.Message); writer.WriteLine(); } }
private static void WarnFailedToLoadAssembly(string assemblyFile, Exception e) { var outputWriter = new DefaultOutputWriter(Console.Write); outputWriter.Write( "Warning: FakeItEasy failed to load assembly '{0}' while scanning for extension points. Any IArgumentValueFormatters, IDummyDefinitions, and IFakeConfigurators in that assembly will not be available.", assemblyFile); outputWriter.WriteLine(); using (outputWriter.Indent()) { outputWriter.Write(e.Message); outputWriter.WriteLine(); } }