public void should_add_to_set_one_distinct_pawns_from_two_instances_with_id() { // Setup var set = new HashSet <BlsPawn>(); BasicPawn p1 = new BasicPawn { Name = "p1" }; p1.SetId("id_of_p"); // Act set.Add(p1); set.Add(p1); // Assert Assert.Single(set); }
public void should_add_to_set_two_distinct_pawns_with_one_id() { // Setup var set = new HashSet <BlsPawn>(); BasicPawn p1 = new BasicPawn { Name = "p1" }; BasicPawn p2 = new BasicPawn { Name = "p2" }; p2.SetId("id_of_p2"); // Act set.Add(p1); set.Add(p2); // Assert Assert.Equal(2, set.Count); }
public void should_be_able_to_get_pawn_by_id() { // Setup var basicPawn = new BasicPawn { Name = "Name" }; basicPawn.SetId("123_id"); var basicPawnContainer = new BlGraphContainer { BlContainerName = "BasicPawn", StorageContainerName = "BasicPawn", Properties = new List <BlContainerProp>() }; var containerList = new List <BlGraphContainer> { basicPawnContainer }; var graphMock = new Mock <IBlGraph>(); graphMock.Setup(graph => graph.GetStorageContainerNameForPawn(It.IsAny <BasicPawn>())).Returns("BasicPawn"); graphMock.Setup(graph => graph.CompiledCollections).Returns(containerList); var storageProviderMock = new Mock <IBlStorageProvider>(); storageProviderMock.Setup(provider => provider.GetById <BasicPawn>(It.IsAny <string>(), It.IsAny <string>())).Returns(basicPawn); var bls = new Bls(storageProviderMock.Object, graphMock.Object); bls.RegisterBlPawns(new BasicPawn()); // Act var found = bls.GetById <BasicPawn>("123"); // Assert Assert.NotNull(found); storageProviderMock.Verify(provider => provider.GetById <BasicPawn>("123", "BasicPawn"), Times.Once()); }