protected MessageServiceTestBase() { _sqlConnectionFactoryMock.Setup(x => x.CreateConnection()).Returns(It.IsAny <SqlConnection>()); _unitOfWorkMock = new Mock <UnitOfWork>(_sqlConnectionFactoryMock.Object, new TransactionConfiguration()).As <IUnitOfWork>(); _unitOfWorkMock.CallBase = true; _unitOfWorkMock.Setup(x => x.ChannelRepository).Returns(_channelRepositoryMock.Object); _unitOfWorkMock.Setup(x => x.MemberRepository).Returns(_memberRepositoryMock.Object); _unitOfWorkMock.Setup(x => x.MessageRepository).Returns(_messageRepositoryMock.Object); _unitOfWorkMock.Setup(x => x.ForwardMessageRepository).Returns(_forwardMessageRepositoryMock.Object); _unitOfWorkMock.Setup(x => x.ChannelMemberRepository).Returns(_channelMemberRepositoryMock.Object); _unitOfWorkMock.Setup(x => x.AttachmentRepository).Returns(_attachmentRepositoryMock.Object); var messageAttachmentsLimitSectionMock = new Mock <IConfigurationSection>(); messageAttachmentsLimitSectionMock.Setup(x => x.Value).Returns(MessageAttachmentsLimit.ToString()); _configurationMock.Setup(x => x.GetSection("Message:MessageAttachmentsLimit")).Returns(messageAttachmentsLimitSectionMock.Object); var lastMessageReadCountSectionMock = new Mock <IConfigurationSection>(); lastMessageReadCountSectionMock.Setup(x => x.Value).Returns(LastMessageReadCount.ToString()); _configurationMock.Setup(x => x.GetSection("Message:LastMessageReadCount")).Returns(lastMessageReadCountSectionMock.Object); var attachmentConfiguration = new MessagesConfiguration(MessageAttachmentsLimit, LastMessageReadCount); _messageService = new MessageService( _unitOfWorkMock.Object, _domainModelsMapperMock.Object, attachmentConfiguration, _cloudAttachmentProviderMock.Object, _cloudImageProviderMock.Object, _dateTimeProviderMock.Object); }
/// <summary> /// Initializes this instance with JSON data from an API response. /// </summary> /// <param name="data">JSON object</param> public Project(dynamic data) { if (data == null) { return; } this.Key = data.key; this.Name = data.name; this.Countries = Helper.GetStringListFromJsonArray(data.countries); this.Currencies = Helper.GetStringListFromJsonArray(data.currencies); this.Languages = Helper.GetStringListFromJsonArray(data.languages); this.CreatedAt = data.createdAt; this.TrialUntil = data.trialUntil; this.Messages = new MessagesConfiguration(data.messages); }
private static void RegisterAppConfiguration(IServiceCollection serviceCollection) { var configurationPath = GetConfigurationPath(); var configuration = new ConfigurationBuilder() .AddJsonFile(configurationPath, optional: false) .Build(); var twitterConfiguration = new TwitterConfiguration(); var messagesConfiguration = new MessagesConfiguration(); configuration.Bind("TwitterConfiguration", twitterConfiguration); configuration.Bind("MessagesConfiguration", messagesConfiguration); serviceCollection.AddSingleton <ITwitterConfiguration>(twitterConfiguration); serviceCollection.AddSingleton <IMessagesConfiguration>(messagesConfiguration); }
public MessageService( IUnitOfWork unitOfWork, IDomainModelsMapper domainModelsMapper, MessagesConfiguration messagesConfiguration, ICloudAttachmentProvider cloudAttachmentProvider, ICloudImageProvider cloudImageProvider, IDateTimeProvider dateTimeProvider) : base(unitOfWork, domainModelsMapper) { Ensure.That(messagesConfiguration).IsNotNull(); Ensure.That(cloudAttachmentProvider).IsNotNull(); Ensure.That(dateTimeProvider).IsNotNull(); _messagesConfiguration = messagesConfiguration; _cloudAttachmentProvider = cloudAttachmentProvider; _cloudImageProvider = cloudImageProvider; _dateTimeProvider = dateTimeProvider; }