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]
|
[Test]
|
||||||
public void CreateCommentIfDoesNotExist()
|
public void CreateCommentIfDoesNotExist()
|
||||||
{
|
{
|
||||||
|
CommentPool.Default.Reset();
|
||||||
int n = CommentPool.Default.Count;
|
int n = CommentPool.Default.Count;
|
||||||
ItemComment i = CommentPool.Default.GetCommentFor("item \"<>\"");
|
ItemComment i = CommentPool.Default.GetCommentFor("item \"<>\"");
|
||||||
Assert.AreEqual(n + 1, CommentPool.Default.Count);
|
Assert.AreEqual(n + 1, CommentPool.Default.Count);
|
||||||
|
@ -38,5 +38,39 @@ namespace Tests.ViewModels
|
|||||||
Assert.AreEqual(comment.Suffix, vm.Suffix);
|
Assert.AreEqual(comment.Suffix, vm.Suffix);
|
||||||
Assert.AreEqual(comment.Value, vm.Value);
|
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>
|
/// </summary>
|
||||||
protected virtual void OnFillInComment()
|
protected virtual void OnFillInComment()
|
||||||
{
|
{
|
||||||
|
if (_isFilledIn) return;
|
||||||
|
|
||||||
EventHandler<ItemCommentEventArgs> h = FillInComment;
|
EventHandler<ItemCommentEventArgs> h = FillInComment;
|
||||||
if (h != null)
|
if (h != null)
|
||||||
{
|
{
|
||||||
|
_isFilledIn = true;
|
||||||
h(this, new ItemCommentEventArgs(this));
|
h(this, new ItemCommentEventArgs(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,6 +211,7 @@ namespace zaaReloaded2.Controller.Comments
|
|||||||
|
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
|
bool _isFilledIn;
|
||||||
static readonly Regex _definition =
|
static readonly Regex _definition =
|
||||||
new Regex(@"(?<item>[^""]+)""(?<prefix>[^<]+)?<(?<value>[^>]*)>(?<suffix>[^""]+)?""");
|
new Regex(@"(?<item>[^""]+)""(?<prefix>[^<]+)?<(?<value>[^>]*)>(?<suffix>[^""]+)?""");
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ namespace zaaReloaded2.ViewModels
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _itemComment.Value;
|
return _value;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@ namespace zaaReloaded2.ViewModels
|
|||||||
|
|
||||||
#region Commands
|
#region Commands
|
||||||
|
|
||||||
DelegatingCommand SaveCommand
|
public DelegatingCommand SaveCommand
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
<DockPanel Margin="0 10 0 10">
|
<DockPanel Margin="0 10 0 10">
|
||||||
<TextBlock DockPanel.Dock="Left" Text="{Binding Prefix}" VerticalAlignment="Center" />
|
<TextBlock DockPanel.Dock="Left" Text="{Binding Prefix}" VerticalAlignment="Center" />
|
||||||
<TextBlock DockPanel.Dock="Right" Text="{Binding Suffix}" 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"
|
MinWidth="120" MaxWidth="240" VerticalAlignment="Center"
|
||||||
x:Name="ValueTextBox" Margin="5 0 5 0" />
|
x:Name="ValueTextBox" Margin="5 0 5 0" />
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
Loading…
Reference in New Issue
Block a user