Skip to content

Commit 4ce37ed

Browse files
committed
fixing the build errors
1 parent d85323f commit 4ce37ed

File tree

3 files changed

+106
-27
lines changed

3 files changed

+106
-27
lines changed

sdk/communication/Azure.Communication.CallAutomation/src/Azure.Communication.CallAutomation.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<PackageTags>Microsoft Azure Communication CallAutomation Service;Microsoft;Azure;Azure Communication Service;Azure Communication CallAutomation Service;Calling;Communication;$(PackageCommonTags)</PackageTags>
1212
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
1313
<IncludeOperationsSharedSource>true</IncludeOperationsSharedSource>
14+
<NoWarn>$(NoWarn);AZC0035</NoWarn>
15+
<IncludeAutorestDependency>true</IncludeAutorestDependency>
16+
<AotCompatOptOut>true</AotCompatOptOut>
1417
</PropertyGroup>
1518

1619
<ItemGroup>

sdk/communication/Azure.Communication.CallAutomation/src/Models/CallAutomationModelFactory.cs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,5 +611,96 @@ public static IncomingCall IncomingCall(CommunicationIdentifier to = null, Commu
611611

612612
return new IncomingCall(internalObject);
613613
}
614+
615+
/// <summary>
616+
/// Initializes a new instance of audio data.
617+
/// </summary>
618+
/// <param name="data">Base64 encoded audio data.</param>
619+
/// <param name="timestamp">The timestamp of when the audio was captured.</param>
620+
/// <param name="participantId">The identifier of the participant who sent the audio.</param>
621+
/// <param name="silent">Indicates if the audio data represents silence.</param>
622+
/// <returns>A new instance of <see cref="AudioData"/> for mocking.</returns>
623+
public static AudioData AudioData(
624+
string data,
625+
DateTime timestamp,
626+
string participantId,
627+
bool silent)
628+
{
629+
return new AudioData(data, timestamp, participantId, silent);
630+
}
631+
632+
/// <summary>
633+
/// Initializes a new instance of audio meta data.
634+
/// </summary>
635+
/// <param name="mediaSubscriptionId">The media subscription id.</param>
636+
/// <param name="encoding">The audio encoding.</param>
637+
/// <param name="sampleRate">The audio sample rate.</param>
638+
/// <param name="channels">The number of audio channels.</param>
639+
/// <param name="length">The length of the audio in milliseconds.</param>
640+
/// <returns>A new instance of <see cref="AudioMetadata"/> for mocking.</returns>
641+
public static AudioMetadata AudioMetadata(
642+
string mediaSubscriptionId,
643+
string encoding,
644+
int sampleRate,
645+
int channels,
646+
int length)
647+
{
648+
var internalObject = new AudioMetadataInternal
649+
{
650+
MediaSubscriptionId = mediaSubscriptionId,
651+
Encoding = encoding,
652+
SampleRate = sampleRate,
653+
Channels = channels,
654+
Length = length
655+
};
656+
return new AudioMetadata(internalObject);
657+
}
658+
659+
/// <summary>
660+
/// Initializes a new instance of transcription data.
661+
/// </summary>
662+
/// <param name="text">The transcribed text.</param>
663+
/// <param name="format">The format of the transcription.</param>
664+
/// <param name="confidence">The confidence score of the transcription.</param>
665+
/// <param name="offset">The offset of the transcription in the audio stream.</param>
666+
/// <param name="duration">The duration of the transcription in milliseconds.</param>
667+
/// <param name="words">The list of words in the transcription.</param>
668+
/// <param name="participantRawID">The raw ID of the participant who spoke.</param>
669+
/// <param name="resultState">The result state of the transcription.</param>
670+
/// <returns>A new instance of <see cref="TranscriptionData"/> for mocking.</returns>
671+
public static TranscriptionData TranscriptionData(
672+
string text,
673+
string format,
674+
double confidence,
675+
ulong offset,
676+
ulong duration,
677+
IEnumerable<WordData> words,
678+
string participantRawID,
679+
string resultState)
680+
{
681+
IEnumerable<WordData> wordData = words.Select(w => new WordData { Text = w.Text, Offset = w.Offset, Duration = w.Duration });
682+
return new TranscriptionData
683+
(
684+
text,
685+
format,
686+
confidence,
687+
offset,
688+
duration,
689+
wordData,
690+
participantRawID,
691+
resultState
692+
);
693+
}
694+
695+
/// <summary>
696+
/// Initializes a new instance of out streaming data.
697+
/// </summary>
698+
/// <param name="kind">The media kind.</param>
699+
/// <returns>A new instance of <see cref="OutStreamingData"/> for mocking.</returns>
700+
public static OutStreamingData OutStreamingData(
701+
MediaKind kind)
702+
{
703+
return new OutStreamingData(kind);
704+
}
614705
}
615706
}

sdk/communication/Azure.Communication.CallAutomation/tests/Models/CallAutomationModelFactoryTests.cs

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,39 +58,25 @@ public void CallAutomationModelFactoryCanInstantiateTranscriptionData()
5858
var text = "Hello World";
5959
var format = "display";
6060
var confidence = 0.95;
61-
var offset = 1000L;
62-
var duration = 2000L;
63-
var words = new List<WordData> { CallAutomationModelFactory.WordData("Hello", 1000, 500) };
61+
ulong offset = 1000;
62+
ulong duration = 2000;
63+
var words = new List<WordData> { new WordData { Text = "Hello", Offset = 1000, Duration = 500 } };
6464
var participantRawID = "participant123";
65-
var resultState = TranscriptionResultState.Final;
65+
var resultState = "final";
6666

6767
var transcriptionData = CallAutomationModelFactory.TranscriptionData(text, format, confidence, offset, duration, words, participantRawID, resultState);
6868

6969
Assert.AreEqual(text, transcriptionData.Text);
7070
Assert.AreEqual(format, transcriptionData.Format);
7171
Assert.AreEqual(confidence, transcriptionData.Confidence);
72-
Assert.AreEqual(TimeSpan.FromTicks(offset), transcriptionData.Offset);
73-
Assert.AreEqual(TimeSpan.FromTicks(duration), transcriptionData.Duration);
72+
Assert.AreEqual(offset, transcriptionData.Offset);
73+
Assert.AreEqual(duration, transcriptionData.Duration);
7474
Assert.AreEqual(CommunicationIdentifier.FromRawId(participantRawID), transcriptionData.Participant);
75-
Assert.AreEqual(resultState, transcriptionData.ResultState);
75+
Assert.AreEqual(resultState, transcriptionData.ResultStatus);
7676
Assert.IsNotNull(transcriptionData.Words);
7777
Assert.AreEqual(1, transcriptionData.Words.Count());
7878
}
7979

80-
[Test]
81-
public void CallAutomationModelFactoryCanInstantiateWordData()
82-
{
83-
var text = "Hello";
84-
var offset = 1000L;
85-
var duration = 500L;
86-
87-
var wordData = CallAutomationModelFactory.WordData(text, offset, duration);
88-
89-
Assert.AreEqual(text, wordData.Text);
90-
Assert.AreEqual(TimeSpan.FromTicks(offset), wordData.Offset);
91-
Assert.AreEqual(TimeSpan.FromTicks(duration), wordData.Duration);
92-
}
93-
9480
[Test]
9581
public void CallAutomationModelFactoryCanInstantiateOutStreamingData()
9682
{
@@ -384,17 +370,15 @@ public void CallAutomationModelFactoryCanInstantiatePlayFailed()
384370
var correlationId = "correlation123";
385371
var operationContext = "testContext";
386372
var resultInformation = CallAutomationModelFactory.ResultInformation(400, 1, "Failed");
387-
var failedPlaySourceIndex = 0;
388373

389374
var eventResult = CallAutomationModelFactory.PlayFailed(
390-
callConnectionId, serverCallId, correlationId, operationContext, resultInformation, failedPlaySourceIndex);
375+
callConnectionId, serverCallId, correlationId, operationContext, resultInformation);
391376

392377
Assert.AreEqual(callConnectionId, eventResult.CallConnectionId);
393378
Assert.AreEqual(serverCallId, eventResult.ServerCallId);
394379
Assert.AreEqual(correlationId, eventResult.CorrelationId);
395380
Assert.AreEqual(operationContext, eventResult.OperationContext);
396381
Assert.AreEqual(resultInformation, eventResult.ResultInformation);
397-
Assert.AreEqual(failedPlaySourceIndex, eventResult.FailedPlaySourceIndex);
398382
}
399383

400384
[Test]
@@ -409,7 +393,7 @@ public void CallAutomationModelFactoryCanInstantiateContinuousDtmfRecognitionTon
409393
var operationContext = "testContext";
410394

411395
var eventResult = CallAutomationModelFactory.ContinuousDtmfRecognitionToneReceived(
412-
sequenceId, tone, callConnectionId, serverCallId, correlationId, resultInformation, operationContext);
396+
resultInformation, sequenceId, tone, operationContext, callConnectionId, serverCallId, correlationId);
413397

414398
Assert.AreEqual(sequenceId, eventResult.SequenceId);
415399
Assert.AreEqual(tone, eventResult.Tone);
@@ -427,13 +411,14 @@ public void CallAutomationModelFactoryCanInstantiateRecordingStateChanged()
427411
var serverCallId = "server123";
428412
var correlationId = "correlation123";
429413
var recordingId = "recording123";
414+
var operationContext = "testContext";
430415
var state = RecordingState.Active;
431416
var startDateTime = DateTimeOffset.UtcNow;
432417
var recordingKind = RecordingKind.AzureCommunicationServices;
433418
var resultInformation = CallAutomationModelFactory.ResultInformation(200, 0, "Success");
434419

435-
var eventResult = CallAutomationModelFactory.RecordingStateChanged(
436-
callConnectionId, serverCallId, correlationId, recordingId, state, startDateTime, recordingKind, resultInformation);
420+
var eventResult = CallAutomationModelFactory.RecordingStateChanged(recordingId,
421+
state, startDateTime, recordingKind, operationContext, resultInformation, callConnectionId, serverCallId, correlationId);
437422

438423
Assert.AreEqual(callConnectionId, eventResult.CallConnectionId);
439424
Assert.AreEqual(serverCallId, eventResult.ServerCallId);

0 commit comments

Comments
 (0)