public void Should_throw_id_generation_exception_when_id_has_not_been_assigned() { var generator = new AssignedGenerator(); var idMap = new IdMap("Id", x => null, (x, y) => { }, generator, new Mock<IValueConverter>().Object, null); var mockClassMap = new Mock<ClassMap>(typeof(int)); var mockMongoSession = new Mock<IMongoSessionImplementor>(); mockMongoSession.Setup(x => x.MappingStore.GetClassMapFor(It.IsAny<Type>())).Returns(mockClassMap.Object); mockClassMap.SetupGet(x => x.IdMap).Returns(idMap); generator.Generate("setat", mockMongoSession.Object); }
public void Should_return_entity_id_when_set() { var generator = new AssignedGenerator(); var idMap = new IdMap("Id", x => 42, (x, y) => { }, generator, new Mock<IValueConverter>().Object, null); var mockClassMap = new Mock<ClassMap>(typeof(int)); var mockMongoSession = new Mock<IMongoSessionImplementor>(); mockMongoSession.Setup(x => x.MappingStore.GetClassMapFor(It.IsAny<Type>())).Returns(mockClassMap.Object); mockClassMap.SetupGet(x => x.IdMap).Returns(idMap); var id = (int)generator.Generate("setat", mockMongoSession.Object); Assert.AreEqual(42, id); }