public void Support_absolute_audio_time() { var ctx = new ContextFor <WaveformPlayerViewModel>(); var formatter = new DateTimeFormatter("yyyy-MM-dd HH:mm:ss"); ctx.Use <IAbsoluteTimeFormatter>(formatter); var sut = ctx.BuildSut(); sut.StartTime.Should().BeNull("no start time by default"); sut.HasCurrentTime.Should().BeFalse(); sut.CurrentTime.Should().BeNullOrWhiteSpace(); var d = DateTimeOffset.UtcNow; sut.StartTime = d; sut.HasCurrentTime.Should().BeTrue(); var expected = formatter.Format(d); sut.CurrentTime.Should().Be(expected); var position = TimeSpan.FromSeconds(sut.Player.Duration); sut.Player.Position = position.TotalSeconds; expected = formatter.Format(d + position); sut.CurrentTime.Should().Be(expected); }
public void Format(string formatString) { var sut = new DateTimeFormatter(formatString); var d = DateTimeOffset.UtcNow; sut.Format(d).Should().Be(d.ToString(formatString)); }