public async Task SnapshotStore_FindAsyncWithMaxVersionReturnsInvokesDeserializeOnIAggregateSerializer() { var options = PopulateContext(); using (var context = new InfrastructureContext(options)) { var mockSerializer = new Mock <IAggregateSerializer>(); mockSerializer.Setup(s => s.Deserialize <FakeAggregate>(It.IsAny <byte[]>())) .Returns <byte[]>(bytes => { var payload = Encoding.UTF8.GetString(bytes); return(JsonConvert.DeserializeObject <FakeAggregate>( payload, new JsonSerializerSettings { ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Full, TypeNameHandling = TypeNameHandling.All, ContractResolver = new Serialization.NonPublicPropertiesContractResolver() })); }); var sut = new SnapshotStore(mockSerializer.Object, context); var aggregate = await sut.GetByIdAsync <FakeAggregate>(ToGuid(1), 10); mockSerializer.Setup(s => s.Deserialize <FakeAggregate>(It.IsAny <byte[]>())); } }