1b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer#region Copyright notice and license 2a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// Protocol Buffers - Google's data interchange format 3b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// Copyright 2016 Google Inc. All rights reserved. 4afb4b72037e3f13db208590fc782c4bc8e27f862Jeff Davidson// https://developers.google.com/protocol-buffers/ 5a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// 6a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// Redistribution and use in source and binary forms, with or without 7a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// modification, are permitted provided that the following conditions are 8a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// met: 9a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// 10a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// * Redistributions of source code must retain the above copyright 11a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// notice, this list of conditions and the following disclaimer. 12a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// * Redistributions in binary form must reproduce the above 13a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// copyright notice, this list of conditions and the following disclaimer 14a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// in the documentation and/or other materials provided with the 15a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// distribution. 16a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// * Neither the name of Google Inc. nor the names of its 17a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// contributors may be used to endorse or promote products derived from 18a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// this software without specific prior written permission. 19a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// 20a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer#endregion 32a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson 33a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson 34b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammerusing NUnit.Framework; 35a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson 36b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammernamespace Google.Protobuf.WellKnownTypes 37b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer{ 38b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer public class FieldMaskTest 39b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer { 40b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer [Test] 41b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer [TestCase("foo__bar")] 42b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer [TestCase("foo_3_ar")] 43b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer [TestCase("fooBar")] 44b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer public void ToString_Invalid(string input) 45b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer { 46b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer var mask = new FieldMask { Paths = { input } }; 47b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer var text = mask.ToString(); 48b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer // More specific test below 49b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer Assert.That(text, Is.StringContaining("@warning")); 50b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer Assert.That(text, Is.StringContaining(input)); 51b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer } 52b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer 53b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer [Test] 54b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer public void ToString_Invalid_Precise() 55b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer { 56b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer var mask = new FieldMask { Paths = { "x", "foo__bar", @"x\y" } }; 57b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer Assert.AreEqual( 58b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer "{ \"@warning\": \"Invalid FieldMask\", \"paths\": [ \"x\", \"foo__bar\", \"x\\\\y\" ] }", 59b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer mask.ToString()); 60b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer } 61a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson } 62a3b2a6da25a76f17c73d31def3952feb0fd2296eJeff Davidson} 63