ProtoCompileCommandLinePrinterTest.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #region Copyright notice and license
  2. // Copyright 2018 gRPC authors.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #endregion
  16. using Microsoft.Build.Framework;
  17. using Moq;
  18. using NUnit.Framework;
  19. namespace Grpc.Tools.Tests
  20. {
  21. public class ProtoCompileCommandLinePrinterTest : ProtoCompileBasicTest
  22. {
  23. [SetUp]
  24. public new void SetUp()
  25. {
  26. _task.Generator = "csharp";
  27. _task.OutputDir = "outdir";
  28. _task.ProtoBuf = Utils.MakeSimpleItems("a.proto");
  29. _mockEngine
  30. .Setup(me => me.LogMessageEvent(It.IsAny<BuildMessageEventArgs>()))
  31. .Callback((BuildMessageEventArgs e) =>
  32. Assert.Fail($"Error logged by build engine:\n{e.Message}"))
  33. .Verifiable("Command line was not output by the task.");
  34. }
  35. void ExecuteExpectSuccess()
  36. {
  37. _mockEngine
  38. .Setup(me => me.LogErrorEvent(It.IsAny<BuildErrorEventArgs>()))
  39. .Callback((BuildErrorEventArgs e) =>
  40. Assert.Fail($"Error logged by build engine:\n{e.Message}"));
  41. bool result = _task.Execute();
  42. Assert.IsTrue(result);
  43. }
  44. };
  45. }