This file contains hidden or 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
| curl -X PUT \ | |
| http://localhost:9200/shopping_index \ | |
| -H 'Cache-Control: no-cache' \ | |
| -H 'Content-Type: application/json' \ | |
| -d '{ | |
| "settings": { | |
| "number_of_shards": 1, | |
| "number_of_replicas": 0, | |
| "analysis": { | |
| "analyzer": { |
This file contains hidden or 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
| [Theory, ClassData(typeof(CultureTestTheoryData))] | |
| public void ToPrettyDate_ShouldAssertsTrue_WhenCultureIsDefined(CultureTestParameter parameter) | |
| { | |
| var actual = parameter.Actual.ToPrettyDate(parameter.Culture); | |
| var expected = parameter.Expected; | |
| Assert.Equal(expected, actual); | |
| } |
This file contains hidden or 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.Globalization; | |
| using test.poco; | |
| using Xunit; | |
| namespace test.theory | |
| { | |
| public class CultureTestTheoryData : TheoryData<CultureTestParameter> | |
| { | |
| public CultureTestTheoryData() |
This file contains hidden or 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
| public static List<CultureTestParameter[]> StaticParameter => new List<CultureTestParameter[]> | |
| { | |
| new CultureTestParameter[] | |
| { | |
| new CultureTestParameter | |
| { | |
| Culture = CultureInfo.CreateSpecificCulture("it-IT"), | |
| Actual = new DateTime(1988, 06, 05), | |
| Expected = "05 giugno 1988" | |
| } |
This file contains hidden or 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
| [Theory, MemberData(nameof(StaticParameter))] | |
| public void ToPrettyDate_ShouldAssertTrue_WhenCultureIsItalian(CultureTestParameter parameter) | |
| { | |
| var actual = parameter.Actual.ToPrettyDate(parameter.Culture); | |
| var expected = parameter.Expected; | |
| Assert.Equal(expected, actual); | |
| } |
This file contains hidden or 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.Globalization; | |
| namespace test.poco | |
| { | |
| public class CultureTestParameter | |
| { | |
| public CultureInfo Culture { get; set; } | |
| public DateTime Actual { get; set; } | |
| public string Expected { get; set; } |
This file contains hidden or 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
| [Theory, InlineData(new object[] { "de-DE", "2017.12.19", "19 Dezember 2017" })] | |
| public void ToPrettyDate_ShouldAssertTrue_WhenCultureIsGerman(string cultureCode, string textDate, string expected) | |
| { | |
| var culture = CultureInfo.CreateSpecificCulture(cultureCode); | |
| var date = DateTime.ParseExact(textDate, "yyyy.MM.dd", culture); | |
| var actual = date.ToPrettyDate(culture); | |
| Assert.Equal(expected, actual); | |
| } |
This file contains hidden or 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
| [Fact] | |
| public void ToPrettyDate_ShouldArgumentNullException_WhenCultureIsNull() | |
| { | |
| var result = Record.Exception(() => DateTime.Now.ToPrettyDate(null)); | |
| Assert.NotNull(result); | |
| var exception = Assert.IsType<ArgumentNullException>(result); | |
| var actual = exception.ParamName; | |
| const string expected = "culture"; | |
| Assert.Equal(expected, actual); | |
| } |
This file contains hidden or 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.Collections.Generic; | |
| using System.Globalization; | |
| using System.Text; | |
| namespace framework.extension | |
| { | |
| public static class DateTimeExtensions | |
| { | |
| public static string ToPrettyDate(this DateTime date, CultureInfo culture) |
This file contains hidden or 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
| services.AddDistributedRedisCache((cache) => | |
| { | |
| cache.InstanceName = appConfig.Name; | |
| cache.Configuration = redisConfig.Host; | |
| }); |