Skip to content

Commit

Permalink
MinimumAlarm with test
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlopez committed Jul 16, 2011
1 parent 6c6e06d commit 6517db1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions AjVars.Tests/AlarmTests.cs
Expand Up @@ -42,5 +42,19 @@ public void RaiseNoAlarm()

Assert.AreEqual(0, count);
}

[TestMethod]
public void RaiseMinimumAlarm()
{
int count = 0;
this.integerVariable.Value = 20;

MinimumAlarm<int> alarm = new MinimumAlarm<int>(this.integerVariable, 10);
alarm.NewAlarm += (oldvalue, newvalue) => count++;

this.integerVariable.Value = 5;

Assert.AreEqual(1, count);
}
}
}
1 change: 1 addition & 0 deletions AjVars/AjVars.csproj
Expand Up @@ -47,6 +47,7 @@
<ItemGroup>
<Compile Include="Alarm.cs" />
<Compile Include="ByteMemory.cs" />
<Compile Include="MinimumAlarm.cs" />
<Compile Include="ShortVariable.cs" />
<Compile Include="IntegerVariable.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
15 changes: 15 additions & 0 deletions AjVars/MinimumAlarm.cs
@@ -0,0 +1,15 @@
namespace AjVars
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MinimumAlarm<T> : Alarm<T> where T : IComparable
{
public MinimumAlarm(Variable<T> variable, T value)
: base(variable, (oldvalue, newvalue) => newvalue.CompareTo(value) < 0)
{
}
}
}

0 comments on commit 6517db1

Please sign in to comment.