コード例 #1
0
ファイル: ClockTests.cs プロジェクト: 1109531320/-
        public void CanGenerateHoursButtons()
        {
            var clock = new Clock();

            clock.ApplyDefaultStyle();

            Canvas hoursCanvas    = clock.FindVisualChild <Canvas>(Clock.HoursCanvasPartName);
            var    buttonContents = hoursCanvas.GetVisualChildren <ClockItemButton>().Select(x => x.Content.ToString());

            var expected = Enumerable.Range(1, 12).Select(x => $"{x:0}");

            Assert.Equal(expected.OrderBy(x => x), buttonContents.OrderBy(x => x));
        }
コード例 #2
0
    public void TimeChangedEvent_WhenTimeChanges_EventIsRaised()
    {
        var clock = new Clock();

        clock.ApplyDefaultStyle();
        List <TimeChangedEventArgs> invocations = new();

        clock.TimeChanged += OnTimeChanged;

        void OnTimeChanged(object?sender, TimeChangedEventArgs e)
        => invocations.Add(e);

        DateTime now = DateTime.Now;

        clock.Time  = now;
        clock.Time += TimeSpan.FromMinutes(-2);

        Assert.Equal(2, invocations.Count);

        Assert.Equal(default, invocations[0].OldTime);