Skip to content

Commit

Permalink
Added MessageStore property to Session (like QF and QF/j have) and a …
Browse files Browse the repository at this point in the history
…unit test to demonstrate it.
  • Loading branch information
mgatny committed Jan 15, 2013
1 parent f8573ef commit 0324b4a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions QuickFIXn/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public partial class Session
#region Properties

// state
public IMessageStore MessageStore { get { return state_.MessageStore; } }
public ILog Log { get { return state_.Log; } }
public bool IsInitiator { get { return state_.IsInitiator; } }
public bool IsAcceptor { get { return !state_.IsInitiator; } }
Expand Down
8 changes: 4 additions & 4 deletions UnitTests/SessionScheduleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public void testLocalTimeTimeZoneConflict()
settings.SetString(QuickFix.SessionSettings.END_TIME, "00:12:00");
settings.SetString(QuickFix.SessionSettings.TIME_ZONE, "Doh");
settings.SetString(QuickFix.SessionSettings.USE_LOCAL_TIME, "Y");
settings.SetString(QuickFix.SessionSettings.TIME_ZONE, "Eastern Standard Time");
settings.SetString(QuickFix.SessionSettings.TIME_ZONE, "America/Detroit");

Assert.Throws(typeof (QuickFix.ConfigError), delegate { new QuickFix.SessionSchedule(settings); });
}
Expand All @@ -309,7 +309,7 @@ public void testTimeZone()
QuickFix.Dictionary settings = new QuickFix.Dictionary();
settings.SetString(QuickFix.SessionSettings.START_TIME, "09:30:00");
settings.SetString(QuickFix.SessionSettings.END_TIME, "16:00:00");
settings.SetString(QuickFix.SessionSettings.TIME_ZONE, "Eastern Standard Time");
settings.SetString(QuickFix.SessionSettings.TIME_ZONE, "America/Detroit");

QuickFix.SessionSchedule sched = new QuickFix.SessionSchedule(settings);

Expand Down Expand Up @@ -359,7 +359,7 @@ public void testLastEndTime_DailySessions()
settings = new QuickFix.Dictionary();
settings.SetString(QuickFix.SessionSettings.START_TIME, "04:30:00"); // 09:30:00 utc
settings.SetString(QuickFix.SessionSettings.END_TIME, "11:00:00"); // 16:00:00 utc
settings.SetString(QuickFix.SessionSettings.TIME_ZONE, "Eastern Standard Time"); //-5
settings.SetString(QuickFix.SessionSettings.TIME_ZONE, "America/Detroit"); //-5
sched = new QuickFix.SessionSchedule(settings);

// before starttime
Expand Down Expand Up @@ -399,7 +399,7 @@ public void testLastEndTime_WeeklySessions()
settings = new QuickFix.Dictionary();
settings.SetString(QuickFix.SessionSettings.START_TIME, "04:30:00"); // 09:30:00 utc
settings.SetString(QuickFix.SessionSettings.END_TIME, "11:00:00"); // 16:00:00 utc
settings.SetString(QuickFix.SessionSettings.TIME_ZONE, "Eastern Standard Time"); //-5
settings.SetString(QuickFix.SessionSettings.TIME_ZONE, "America/Detroit"); //-5
settings.SetDay(QuickFix.SessionSettings.START_DAY, System.DayOfWeek.Monday);
settings.SetDay(QuickFix.SessionSettings.END_DAY, System.DayOfWeek.Friday);
sched = new QuickFix.SessionSchedule(settings);
Expand Down
16 changes: 16 additions & 0 deletions UnitTests/SessionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -556,5 +556,21 @@ public void TestGettingIsAcceptor()
{
Assert.That(session2.IsAcceptor, Is.EqualTo(false));
}

[Test]
public void TestMessageStoreAccessor()
{
List<string> messages = new List<string>();

messages.Clear();
session.MessageStore.Get(0, 100, messages);
Assert.That(messages.Count, Is.EqualTo(0));

Logon();

messages.Clear();
session.MessageStore.Get(0, 100, messages);
Assert.That(messages.Count, Is.EqualTo(1)); // logon response
}
}
}

0 comments on commit 0324b4a

Please sign in to comment.