Created
July 29, 2019 18:28
-
-
Save eouw0o83hf/19aa24564067fbf7bdcb2321a4afc87b to your computer and use it in GitHub Desktop.
CrAzYcAsE test extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using Xunit; | |
namespace Example.Tests | |
{ | |
public static class TestExtensions | |
{ | |
public static string ToCrAzYcAsE(this string input) | |
=> input | |
?.WithIndex() | |
?.Aggregate("", (acc, i) => | |
acc + (i.Index % 2 == 0 ? | |
Char.ToUpper(i.Value) : | |
Char.ToLower(i.Value) | |
) | |
); | |
} | |
/// M E T A | |
/// E | |
/// T | |
/// A | |
public class TestExtensionsTests | |
{ | |
[Fact] | |
public void ToCrAzYcAsE_gIvEnNuLl_ShOuLdReTuRnNuLl() | |
=> Assert.Null(TestExtensions.ToCrAzYcAsE(null)); | |
[Theory] | |
[InlineData("flatearth")] | |
[InlineData("FLATEARTH")] | |
[InlineData("flatEARTH")] | |
public void ToCrAzYcAsE_sHoUlDcRaZyCaSeThEiNpUt(string input) | |
=> Assert.Equal("FlAtEaRtH", input.ToCrAzYcAsE()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment