public void Duration_should_be_negative_if_End_less_than_Start() { var sut = new AudioSelectionViewModel { Start = 1, End = 0 }; sut.Duration.Should().BeNegative(); sut.Duration.Should().Be(sut.End - sut.Start); }
public void Changing_Start_or_End_should_raise_DurationChanged() { var sut = new AudioSelectionViewModel(); sut.Top.Should().Be(-1); sut.Height.Should().Be(2); var map = new Dictionary <string, int>(); sut.PropertyChanged += (s, e) => { if (map.ContainsKey(e.PropertyName)) { map[e.PropertyName]++; } else { map[e.PropertyName] = 1; } }; sut.Start = 1.0; map[nameof(sut.Start)].Should().Be(1); map[nameof(sut.Duration)].Should().Be(1); sut.Start.Should().Be(1.0); sut.End = 2.0; map[nameof(sut.End)].Should().Be(1); map[nameof(sut.Duration)].Should().Be(2); sut.End.Should().Be(2.0); sut.Top = 0.2; map[nameof(sut.Top)].Should().Be(1); sut.Top.Should().Be(0.2); sut.Height = 1.0; map[nameof(sut.Height)].Should().Be(1); sut.Height.Should().Be(1.0); var menu = new MenuViewModel(); sut.Menu = menu; map["Menu"].Should().Be(1); sut.Menu.Should().Be(menu); sut.Menu = null; map["Menu"].Should().Be(2); sut.Menu.Should().Be(null); }
public void Notify_property_changes() { var ctx = new ContextFor <WaveformViewModel>(); var sut = ctx.BuildSut(); using (var monitor = sut.Monitor()) { var selection = new AudioSelectionViewModel(); sut.Selection = selection; sut.Selection.Should().BeEquivalentTo(selection); monitor.Should().RaisePropertyChangeFor(x => x.Selection); } using (var monitor = sut.Monitor()) { var selectionMenu = Substitute.For <IMenuViewModel>(); sut.SelectionMenu = selectionMenu; sut.SelectionMenu.Should().Be(selectionMenu); monitor.Should().RaisePropertyChangeFor(x => x.SelectionMenu); } using (var monitor = sut.Monitor()) { sut.TicksEach = 42.0; sut.TicksEach.Should().Be(42); monitor.Should().RaisePropertyChangeFor(x => x.TicksEach); } var brush = new SolidColorBrush(Colors.Red); var points = new PointCollection(); var label = Substitute.For <ILabelVievModel>(); var labels = new[] { label }; sut.Labels = labels; sut.Labels.Should().BeEquivalentTo(labels); using (var monitor = sut.Monitor()) { sut.SelectedLabel = label; sut.SelectedLabel.Should().Be(label); monitor.Should().RaisePropertyChangeFor(x => x.SelectedLabel); } using (var monitor = sut.Monitor()) { sut.UserBrush = brush; sut.UserBrush.Should().Be(brush); monitor.Should().RaisePropertyChangeFor(x => x.UserBrush); } using (var monitor = sut.Monitor()) { sut.SeparationLeftBrush = brush; sut.SeparationLeftBrush.Should().Be(brush); monitor.Should().RaisePropertyChangeFor(x => x.SeparationLeftBrush); } using (var monitor = sut.Monitor()) { sut.SeparationRightBrush = brush; sut.SeparationRightBrush.Should().Be(brush); monitor.Should().RaisePropertyChangeFor(x => x.SeparationRightBrush); } using (var monitor = sut.Monitor()) { sut.UserTextBrush = brush; sut.UserTextBrush.Should().Be(brush); monitor.Should().RaisePropertyChangeFor(x => x.UserTextBrush); } using (var monitor = sut.Monitor()) { sut.PositionBrush = brush; sut.PositionBrush.Should().Be(brush); monitor.Should().RaisePropertyChangeFor(x => x.PositionBrush); } using (var monitor = sut.Monitor()) { sut.SelectionBrush = brush; sut.SelectionBrush.Should().Be(brush); monitor.Should().RaisePropertyChangeFor(x => x.SelectionBrush); } using (var monitor = sut.Monitor()) { sut.SeparationRightBrush = brush; sut.SeparationRightBrush.Should().Be(brush); monitor.Should().RaisePropertyChangeFor(x => x.SeparationRightBrush); } using (var monitor = sut.Monitor()) { sut.UserChannel = points; sut.UserChannel.Should().BeEquivalentTo(points); monitor.Should().RaisePropertyChangeFor(x => x.UserChannel); } using (var monitor = sut.Monitor()) { sut.SeparationLeftChannel = points; sut.SeparationLeftChannel.Should().BeEquivalentTo(points); monitor.Should().RaisePropertyChangeFor(x => x.SeparationLeftChannel); } using (var monitor = sut.Monitor()) { sut.SeparationRightChannel = points; sut.SeparationRightChannel.Should().BeEquivalentTo(points); monitor.Should().RaisePropertyChangeFor(x => x.SeparationRightChannel); } }