public void ShouldLoadPreviuosState() { var storeProvider = new Mock <IStoreProvider>(); storeProvider.Setup(sp => sp.Read(It.IsAny <string>())).Returns("{\"12345\": { \"Id\" : \"12345\", \"Sequence\": 6}}"); var eventState = EventState.Create(storeProvider.Object, new Settings()); var currentSeq = eventState.GetCurrentSequence("Tennis", "12345"); currentSeq.Should().Be(6); }
public void ShouldAddAndRemoveFixtures() { var storeProvider = new Mock <IStoreProvider>(); storeProvider.Setup(sp => sp.Read(It.IsAny <string>())).Throws(new FileNotFoundException()); var eventState = EventState.Create(storeProvider.Object, new Settings()); eventState.AddFixture("football", "1", 1, 1); var currentSeq = eventState.GetCurrentSequence("football", "1"); currentSeq.Should().Be(1); eventState.RemoveFixture("1"); currentSeq = eventState.GetCurrentSequence("football", "1"); currentSeq.Should().Be(-1); }
public void ShouldWorkWithMultiSports() { var storeProvider = new Mock <IStoreProvider>(); storeProvider.Setup(sp => sp.Read(It.IsAny <string>())).Throws(new FileNotFoundException()); var eventState = EventState.Create(storeProvider.Object, new Settings()); eventState.AddFixture("football", "1", 1, 1); eventState.AddFixture("tennis", "2", 2, 1); eventState.AddFixture("rugby", "3", 3, 1); var currentSeq = eventState.GetCurrentSequence("football", "1"); currentSeq.Should().Be(1); currentSeq = eventState.GetCurrentSequence("tennis", "2"); currentSeq.Should().Be(2); currentSeq = eventState.GetCurrentSequence("rugby", "3"); currentSeq.Should().Be(3); }
public void ShouldRemoveInactiveFixtures() { var storeProvider = new Mock <IStoreProvider>(); storeProvider.Setup(sp => sp.Read(It.IsAny <string>())).Throws(new FileNotFoundException()); var eventState = EventState.Create(storeProvider.Object, new Settings()); eventState.AddFixture("basketball", "1", 1, 1); eventState.AddFixture("football", "2", 2, 1); eventState.AddFixture("football", "4", 3, 1); var activeOne = new Mock <IResourceFacade>(); activeOne.Setup(f => f.Id).Returns("1"); activeOne.Setup(f => f.IsMatchOver).Returns(false); var activeThree = new Mock <IResourceFacade>(); activeThree.Setup(f => f.Id).Returns("3"); activeThree.Setup(f => f.IsMatchOver).Returns(false); var inactiveFour = new Mock <IResourceFacade>(); inactiveFour.Setup(f => f.Id).Returns("4"); inactiveFour.Setup(f => f.IsMatchOver).Returns(true); var activeList = new List <IResourceFacade> { activeOne.Object, activeThree.Object, inactiveFour.Object }; eventState.RemoveInactiveFixtures("football", activeList); var currentSeq = eventState.GetCurrentSequence("basketball", "1"); currentSeq.Should().Be(1); currentSeq = eventState.GetCurrentSequence("football", "2"); currentSeq.Should().Be(-1); currentSeq = eventState.GetCurrentSequence("football", "3"); currentSeq.Should().Be(-1); currentSeq = eventState.GetCurrentSequence("football", "4"); currentSeq.Should().Be(-1); }