GeneratorTest.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 Microsoft.Build.Utilities;
  18. using Moq;
  19. using NUnit.Framework;
  20. namespace Grpc.Tools.Tests {
  21. public class GeneratorTest {
  22. protected Mock<IBuildEngine> _mockEngine;
  23. protected TaskLoggingHelper _log;
  24. [SetUp]
  25. public void SetUp() {
  26. _mockEngine = new Mock<IBuildEngine>();
  27. _log = new TaskLoggingHelper(_mockEngine.Object, "dummy");
  28. }
  29. [TestCase("csharp")]
  30. [TestCase("CSharp")]
  31. [TestCase("cpp")]
  32. public void ValidLanguages(string lang) {
  33. Assert.IsNotNull(GeneratorServices.GetForLanguage(lang, _log));
  34. _mockEngine.Verify(me => me.LogErrorEvent(It.IsAny<BuildErrorEventArgs>()), Times.Never);
  35. }
  36. [TestCase("")]
  37. [TestCase("COBOL")]
  38. public void InvalidLanguages(string lang) {
  39. Assert.IsNull(GeneratorServices.GetForLanguage(lang, _log));
  40. _mockEngine.Verify(me => me.LogErrorEvent(It.IsAny<BuildErrorEventArgs>()), Times.Once);
  41. }
  42. };
  43. }