示例#1
0
        public void NullStateShouldThrowException()
        {
            ArgumentNullException exception = Assert.Throws <ArgumentNullException>(
                () => Cigar.Load(null));

            Assert.Equal("state", exception.ParamName);
        }
示例#2
0
        public void ShouldBindStateToProperties()
        {
            CigarState state = new CigarState()
            {
                Id = Guid.NewGuid()
            };

            Cigar cigar = Cigar.Load(state);

            Assert.Equal(state.Id, cigar.Id);
        }
示例#3
0
        /// <inheritdoc />
        public async Task <Cigar> Load(Guid id)
        {
            DynamicParameters parameters = new DynamicParameters();

            parameters.Add("@Id", id, DbType.Guid, ParameterDirection.Input);

            EntityState entityState = await _client.ExecuteInManagedConnectionAsync(connection =>
                                                                                    connection.QuerySingleOrDefaultAsync <EntityState>(
                                                                                        "[Catalog].[Cigars_GetSingle]",
                                                                                        parameters,
                                                                                        commandType: CommandType.StoredProcedure)
                                                                                    );

            if (entityState == null)
            {
                return(null);
            }

            CigarState cigarState
                = _serializer.Deserialize <CigarState>(entityState.SerializedContent);

            return(Cigar.Load(cigarState));
        }