public void It_Throws_An_EntityAlreadySynchedException_If_An_Entity_With_This_Source_And_Id_Already_Exists_In_This_Gaming_Group() { //--arrange var newlyCompletedGame = CreateNewlyCompletedGame(); var applicationLinkage = new ApplicationLinkage { ApplicationName = _expectedApplicationName, EntityId = _expectedEntityId }; newlyCompletedGame.ApplicationLinkages.Add(applicationLinkage); var expectedException = new EntityAlreadySynchedException(_expectedApplicationName, _expectedEntityId, newlyCompletedGame.GamingGroupId.Value); //--act var exception = Assert.Throws<EntityAlreadySynchedException>(() => _autoMocker.ClassUnderTest.Validate(newlyCompletedGame)); //--assert exception.Message.ShouldBe(expectedException.Message); }
public void It_Doesnt_Throw_An_EntityAlreadySynchedException_If_An_Entity_With_This_ApplicationName_Doesnt_Exist() { //--arrange var newlyCompletedGame = CreateNewlyCompletedGame(); var applicationLinkage = new ApplicationLinkage { ApplicationName = "name that doesnt exist", EntityId = _expectedEntityId }; newlyCompletedGame.ApplicationLinkages.Add(applicationLinkage); //--act _autoMocker.ClassUnderTest.Validate(newlyCompletedGame); }
public void It_Throws_An_InvalidSourceException_If_One_Of_The_External_Source_Fields_Is_Set_But_Not_The_Other( string applicationName, string externalSourceEntityId) { //--arrange var newlyCompletedGame = CreateNewlyCompletedGame(); var applicationLinkage = new ApplicationLinkage { ApplicationName = applicationName, EntityId = externalSourceEntityId }; newlyCompletedGame.ApplicationLinkages.Add(applicationLinkage); var expectedException = new InvalidSourceException(applicationName, externalSourceEntityId); //--act var exception = Assert.Throws<InvalidSourceException>(() => _autoMocker.ClassUnderTest.Validate(newlyCompletedGame)); //--assert exception.Message.ShouldBe(expectedException.Message); }
public void ItCreatesAnApplicationLinkageForEachSpecifiedApplicationLinkage() { //--arrange var newlyCompletedPlayedGame = CreateValidNewlyCompletedGame(); var expectedApplicationLinkage1 = new ApplicationLinkage { ApplicationName = "app1", EntityId = "1" }; var expectedApplicationLinkage2 = new ApplicationLinkage { ApplicationName = "app2", EntityId = "2" }; newlyCompletedPlayedGame.ApplicationLinkages = new List<ApplicationLinkage> { expectedApplicationLinkage1, expectedApplicationLinkage2 }; var expectedPlayedGame = new PlayedGame { Id = EXPECTED_PLAYED_GAME_ID }; autoMocker.ClassUnderTest.Expect(partialMock => partialMock.TransformNewlyCompletedGameIntoPlayedGame(null, 0, null, null)) .IgnoreArguments() .Return(expectedPlayedGame); //--act autoMocker.ClassUnderTest.CreatePlayedGame(newlyCompletedPlayedGame, TransactionSource.WebApplication, currentUser); //--assert autoMocker.Get<IApplicationLinker>().AssertWasCalled(mock => mock.LinkApplication( EXPECTED_PLAYED_GAME_ID, expectedApplicationLinkage1.ApplicationName, expectedApplicationLinkage1.EntityId)); autoMocker.Get<IApplicationLinker>().AssertWasCalled(mock => mock.LinkApplication( EXPECTED_PLAYED_GAME_ID, expectedApplicationLinkage2.ApplicationName, expectedApplicationLinkage2.EntityId)); }