Fix filling in comments.
- VERBESSERT: Fehler bei der Kommentaraufforderung wurden behoben.
This commit is contained in:
parent
3ce046a238
commit
2f60c2c5d1
@ -30,6 +30,7 @@ namespace Tests.Controller.Comments
|
||||
[Test]
|
||||
public void CreateCommentIfDoesNotExist()
|
||||
{
|
||||
CommentPool.Default.Reset();
|
||||
int n = CommentPool.Default.Count;
|
||||
ItemComment i = CommentPool.Default.GetCommentFor("item \"<>\"");
|
||||
Assert.AreEqual(n + 1, CommentPool.Default.Count);
|
||||
|
@ -38,5 +38,39 @@ namespace Tests.ViewModels
|
||||
Assert.AreEqual(comment.Suffix, vm.Suffix);
|
||||
Assert.AreEqual(comment.Value, vm.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EnterComment()
|
||||
{
|
||||
ItemComment comment = new ItemComment("TAC", "(Ziel-Talspiegel: ", "", "µg/l)");
|
||||
ItemCommentViewModel vm = new ItemCommentViewModel(comment);
|
||||
vm.Value = "8-10";
|
||||
bool eventRaised = false;
|
||||
vm.RequestCloseView += (sender, args) =>
|
||||
{
|
||||
eventRaised = true;
|
||||
};
|
||||
vm.SaveCommand.Execute(null);
|
||||
Assert.IsTrue(eventRaised, "Event was not raised.");
|
||||
Assert.IsFalse(comment.IsCancelled, "Comment.IsCancelled should be false");
|
||||
Assert.AreEqual("8-10", comment.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CancelComment()
|
||||
{
|
||||
ItemComment comment = new ItemComment("TAC", "(Ziel-Talspiegel: ", "default", "µg/l)");
|
||||
ItemCommentViewModel vm = new ItemCommentViewModel(comment);
|
||||
vm.Value = "blabla";
|
||||
bool eventRaised = false;
|
||||
vm.RequestCloseView += (sender, args) =>
|
||||
{
|
||||
eventRaised = true;
|
||||
};
|
||||
vm.CloseViewCommand.Execute(null);
|
||||
Assert.IsTrue(eventRaised, "Event was not raised.");
|
||||
Assert.IsTrue(comment.IsCancelled, "Comment.IsCancelled should be true");
|
||||
Assert.AreEqual("default", comment.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -197,9 +197,12 @@ namespace zaaReloaded2.Controller.Comments
|
||||
/// </summary>
|
||||
protected virtual void OnFillInComment()
|
||||
{
|
||||
if (_isFilledIn) return;
|
||||
|
||||
EventHandler<ItemCommentEventArgs> h = FillInComment;
|
||||
if (h != null)
|
||||
{
|
||||
_isFilledIn = true;
|
||||
h(this, new ItemCommentEventArgs(this));
|
||||
}
|
||||
}
|
||||
@ -208,6 +211,7 @@ namespace zaaReloaded2.Controller.Comments
|
||||
|
||||
#region Fields
|
||||
|
||||
bool _isFilledIn;
|
||||
static readonly Regex _definition =
|
||||
new Regex(@"(?<item>[^""]+)""(?<prefix>[^<]+)?<(?<value>[^>]*)>(?<suffix>[^""]+)?""");
|
||||
|
||||
|
@ -41,7 +41,7 @@ namespace zaaReloaded2.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return _itemComment.Value;
|
||||
return _value;
|
||||
}
|
||||
set
|
||||
{
|
||||
@ -56,7 +56,7 @@ namespace zaaReloaded2.ViewModels
|
||||
|
||||
#region Commands
|
||||
|
||||
DelegatingCommand SaveCommand
|
||||
public DelegatingCommand SaveCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -42,7 +42,7 @@
|
||||
<DockPanel Margin="0 10 0 10">
|
||||
<TextBlock DockPanel.Dock="Left" Text="{Binding Prefix}" VerticalAlignment="Center" />
|
||||
<TextBlock DockPanel.Dock="Right" Text="{Binding Suffix}" VerticalAlignment="Center" />
|
||||
<TextBox Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=LostFocus}"
|
||||
<TextBox Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
|
||||
MinWidth="120" MaxWidth="240" VerticalAlignment="Center"
|
||||
x:Name="ValueTextBox" Margin="5 0 5 0" />
|
||||
</DockPanel>
|
||||
|
Loading…
Reference in New Issue
Block a user