<commit_before>// Copyright (c) MarinAtanasov. All rights reserved.
// Licensed under the MIT License (MIT). See License.txt in the project root for license information.
//
using AppBrix.Application;
using AppBrix.Configuration.Memory;
using AppBrix.Resolver;
using AppBrix.Tests;
using AppBrix.Time.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;

namespace AppBrix.Time.Tests
{
    [TestClass]
    public class TimeServiceTests
    {
        #region Tests
        [TestMethod]
        public void TestUtcTimeService()
        {
            var app = this.CreateAppWithTimeModule();
            app.Start();
            app.GetConfig<TimeConfig>().Kind = DateTimeKind.Utc;
            app.Reinitialize();
            var timeBefore = DateTime.UtcNow;
            var time = app.GetTime();
            var timeAfter = DateTime.UtcNow;
            Assert.IsTrue(timeBefore <= time, "Before > call");
            Assert.IsTrue(time.Kind == DateTimeKind.Utc, "Kind is not Utc");
            Assert.IsTrue(timeAfter >= time, "After < call");
            app.Stop();
        }

        [TestMethod]
        public void TestLocalTimeService()
        {
            var app = this.CreateAppWithTimeModule();
            app.Start();
            app.GetConfig<TimeConfig>().Kind = DateTimeKind.Local;
            app.Reinitialize();
            var timeBefore = DateTime.Now;
            var time = app.GetTime();
            var timeAfter = DateTime.Now;
            Assert.IsTrue(timeBefore <= time, "Before > call");
            Assert.IsTrue(time.Kind == DateTimeKind.Local, "Kind is not Local");
            Assert.IsTrue(timeAfter >= time, "After < call");
            app.Stop();
        }

        [TestMethod]
        public void TestToUtcTime()
        {
            var app = this.CreateAppWithTimeModule();
            app.Start();
            app.GetConfig<TimeConfig>().Kind = DateTimeKind.Utc;
            app.Reinitialize();
            var time = DateTime.Now;
            var appTime = app.GetTimeService().ToAppTime(time);
            Assert.AreEqual(DateTimeKind.Utc, appTime.Kind, "Kind not converted.");
            Assert.AreEqual(time.ToUniversalTime(), appTime, "Time values do not match.");
            app.Stop();
        }

        [TestMethod]
        public void TestToLocalTime()
        {
            var app = this.CreateAppWithTimeModule();
            app.Start();
            app.GetConfig<TimeConfig>().Kind = DateTimeKind.Local;
            app.Reinitialize();
            var time = DateTime.UtcNow;
            var appTime = app.GetTimeService().ToAppTime(time);
            Assert.AreEqual(DateTimeKind.Local, appTime.Kind, "Kind not converted.");
            Assert.AreEqual(time.ToLocalTime(), appTime, "Time values do not match.");
            app.Stop();
        }
        #endregion

        #region Private methods
        private IApp CreateAppWithTimeModule()
        {
            return TestsUtils.CreateTestApp(
                typeof(ResolverModule),
                typeof(MemoryConfigModule),
                typeof(TimeModule));
        }
        #endregion
    }
}
<commit_msg>Added 2 more tests for converting DateTIme to application time.<commit_after>// Copyright (c) MarinAtanasov. All rights reserved.
// Licensed under the MIT License (MIT). See License.txt in the project root for license information.
//
using AppBrix.Application;
using AppBrix.Configuration.Memory;
using AppBrix.Resolver;
using AppBrix.Tests;
using AppBrix.Time.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;

namespace AppBrix.Time.Tests
{
    [TestClass]
    public class TimeServiceTests
    {
        #region Tests
        [TestMethod]
        public void TestUtcTimeService()
        {
            var app = this.CreateAppWithTimeModule();
            app.Start();
            app.GetConfig<TimeConfig>().Kind = DateTimeKind.Utc;
            app.Reinitialize();
            var timeBefore = DateTime.UtcNow;
            var time = app.GetTime();
            var timeAfter = DateTime.UtcNow;
            Assert.IsTrue(timeBefore <= time, "Before > call");
            Assert.IsTrue(time.Kind == DateTimeKind.Utc, "Kind is not Utc");
            Assert.IsTrue(timeAfter >= time, "After < call");
            app.Stop();
        }

        [TestMethod]
        public void TestLocalTimeService()
        {
            var app = this.CreateAppWithTimeModule();
            app.Start();
            app.GetConfig<TimeConfig>().Kind = DateTimeKind.Local;
            app.Reinitialize();
            var timeBefore = DateTime.Now;
            var time = app.GetTime();
            var timeAfter = DateTime.Now;
            Assert.IsTrue(timeBefore <= time, "Before > call");
            Assert.IsTrue(time.Kind == DateTimeKind.Local, "Kind is not Local");
            Assert.IsTrue(timeAfter >= time, "After < call");
            app.Stop();
        }

        [TestMethod]
        public void TestUtcToUtcTime()
        {
            var app = this.CreateAppWithTimeModule();
            app.Start();
            app.GetConfig<TimeConfig>().Kind = DateTimeKind.Utc;
            app.Reinitialize();
            var time = DateTime.UtcNow;
            var appTime = app.GetTimeService().ToAppTime(time);
            Assert.AreEqual(DateTimeKind.Utc, appTime.Kind, "Kind not converted.");
            Assert.AreEqual(time, appTime, "Time values do not match.");
            app.Stop();
        }

        [TestMethod]
        public void TestLocalToUtcTime()
        {
            var app = this.CreateAppWithTimeModule();
            app.Start();
            app.GetConfig<TimeConfig>().Kind = DateTimeKind.Utc;
            app.Reinitialize();
            var time = DateTime.Now;
            var appTime = app.GetTimeService().ToAppTime(time);
            Assert.AreEqual(DateTimeKind.Utc, appTime.Kind, "Kind not converted.");
            Assert.AreEqual(time.ToUniversalTime(), appTime, "Time values do not match.");
            app.Stop();
        }

        [TestMethod]
        public void TestUtcToLocalTime()
        {
            var app = this.CreateAppWithTimeModule();
            app.Start();
            app.GetConfig<TimeConfig>().Kind = DateTimeKind.Local;
            app.Reinitialize();
            var time = DateTime.UtcNow;
            var appTime = app.GetTimeService().ToAppTime(time);
            Assert.AreEqual(DateTimeKind.Local, appTime.Kind, "Kind not converted.");
            Assert.AreEqual(time.ToLocalTime(), appTime, "Time values do not match.");
            app.Stop();
        }

        [TestMethod]
        public void TestLocalToLocalTime()
        {
            var app = this.CreateAppWithTimeModule();
            app.Start();
            app.GetConfig<TimeConfig>().Kind = DateTimeKind.Local;
            app.Reinitialize();
            var time = DateTime.Now;
            var appTime = app.GetTimeService().ToAppTime(time);
            Assert.AreEqual(DateTimeKind.Local, appTime.Kind, "Kind not converted.");
            Assert.AreEqual(time, appTime, "Time values do not match.");
            app.Stop();
        }
        #endregion

        #region Private methods
        private IApp CreateAppWithTimeModule()
        {
            return TestsUtils.CreateTestApp(
                typeof(ResolverModule),
                typeof(MemoryConfigModule),
                typeof(TimeModule));
        }
        #endregion
    }
}

{'fraction_non_alphanumeric': 0.10888977742236439, 'fraction_numerical': 0.0001332800213248034, 'mean_word_length': 1.9648360331884631, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3208749', 'n_tokens_mistral': 1981, 'n_tokens_neox': 1962, 'n_words': 447}