Click here to Skip to main content
15,886,110 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Task based asyn Pin
anilkumar198613-Feb-19 1:23
anilkumar198613-Feb-19 1:23 
Questionstatement is not valid n a namespace Pin
Member 1384753912-Feb-19 8:07
Member 1384753912-Feb-19 8:07 
AnswerRe: statement is not valid n a namespace Pin
Richard Deeming12-Feb-19 10:05
mveRichard Deeming12-Feb-19 10:05 
GeneralRe: statement is not valid n a namespace Pin
Member 1384753913-Feb-19 5:37
Member 1384753913-Feb-19 5:37 
QuestionMocking a Service call in my Unit Tests Pin
simpledeveloper8-Feb-19 7:31
simpledeveloper8-Feb-19 7:31 
AnswerRe: Mocking a Service call in my Unit Tests Pin
Gerry Schmitz8-Feb-19 10:46
mveGerry Schmitz8-Feb-19 10:46 
GeneralRe: Mocking a Service call in my Unit Tests Pin
simpledeveloper8-Feb-19 10:59
simpledeveloper8-Feb-19 10:59 
GeneralRe: Mocking a Service call in my Unit Tests Pin
simpledeveloper11-Feb-19 8:29
simpledeveloper11-Feb-19 8:29 
I changed my Test method as below:
[TestMethod]
public async Task ServiceAgreementUpdateAddTest()
{
    DateTime dateTime = DateTime.Today;

    var expectedServiceRequest1 = new C1ServiceAgreementUpdateRequest
    {
        C1ServiceAgreementUpdate = new C1ServiceAgreementUpdate
        {
            serviceAgreement = this.serviceAgreementIds[0],
            saChar = new[]
        {
                    new C1ServiceAgreementUpdateSaChar
                    {
                        action = listAction.add,
                        actionSpecified = true,
                        serviceAgreement11 = this.serviceAgreementIds[0],
                        characteristicType3 = characteristicType,
                        characteristicValue2 = characteristicValue,
                        effectiveDate6 = dateTime,
                        effectiveDate6Specified = true,
                        searchCharacteristicValue = searchCharacteristicvalue
                    }
                }
        }
    };


    var expectedServiceRequest2 = new C1ServiceAgreementUpdateRequest
    {
        C1ServiceAgreementUpdate = new C1ServiceAgreementUpdate
        {
            serviceAgreement = this.serviceAgreementIds[0],
            saChar = new[]
        {
                    new C1ServiceAgreementUpdateSaChar
                    {
                        action = listAction.add,
                        actionSpecified = true,
                        serviceAgreement11 = this.serviceAgreementIds[1],
                        characteristicType3 = characteristicType,
                        characteristicValue2 = characteristicValue,
                        effectiveDate6 = dateTime,
                        effectiveDate6Specified = true,
                        searchCharacteristicValue = searchCharacteristicvalue
                    }
                }
        }
    };


    var serviceAgreementCharacteristicRequests = new List<ServiceAgreementCharacteristicRequest>();

    foreach (var serviceAgreementId in this.serviceAgreementIds)
    {
        var request = new ServiceAgreementCharacteristicRequest
        {
            ServiceAgreementId = serviceAgreementId,
            CharacteristicType = characteristicType,
            CharacteristicValue = characteristicValue,
            ActionType = RequestAction.ADD
        };

        serviceAgreementCharacteristicRequests.Add(request);
    }

    this._serviceWrapper.Setup(e => e.UseServiceAsync(It.IsAny<Func<ATC1ServiceAgreementUpdatePortType, Task<C1ServiceAgreementUpdateResponse>>>()))
        .Callback((Func<ATC1ServiceAgreementUpdatePortType, Task<C1ServiceAgreementUpdateResponse>> serviceFunc) => { serviceFunc.Invoke(this._serviceAgreementUdateSvc.Object); })
        .ReturnsAsync(new C1ServiceAgreementUpdateResponse());

    await this._service.ServiceAgreementCharacteristicAsync(serviceAgreementCharacteristicRequests).ConfigureAwait(false);

    this._serviceWrapper.Verify(sw => sw.UseServiceAsync(It.IsAny<Func<ATC1ServiceAgreementUpdatePortType, Task<C1ServiceAgreementUpdateResponse>>>()), Times.Exactly(serviceAgreementCharacteristicRequests.Count));

    //this._serviceAgreementUdateSvc.Verify(svc => svc.C1ServiceAgreementUpdateAsync(It.Is<C1ServiceAgreementUpdateRequest>(x => x.Equals(expectedServiceRequest1))), Times.Once);
    //this._serviceAgreementUdateSvc.Verify(svc => svc.C1ServiceAgreementUpdateAsync(It.Is<C1ServiceAgreementUpdateRequest>(x => x.Equals(expectedServiceRequest2))), Times.Once);
}


I am getting the following error:
Failed   ServiceAgreementUpdateAddTest
Error Message:
 Test method CustomerServiceWeb.Services.Test.ServiceAgreements.ServiceAgreementUpdateProxyTest.ServiceAgreementUpdateAddTest threw exception:
Moq.MockException:
Expected invocation on the mock once, but was 0 times: svc => svc.C1ServiceAgreementUpdateAsync(It.Is<C1ServiceAgreementUpdateRequest>(x => x.Equals(C1ServiceAgreementUpdateRequest)))

Configured setups:
s => s.C1ServiceAgreementUpdateAsync(It.IsAny<C1ServiceAgreementUpdateRequest>())

Performed invocations:
ATC1ServiceAgreementUpdatePortType.C1ServiceAgreementUpdateAsync(C1ServiceAgreementUpdateRequest)
ATC1ServiceAgreementUpdatePortType.C1ServiceAgreementUpdateAsync(C1ServiceAgreementUpdateRequest)
Stack Trace:
    at Moq.Mock.ThrowVerifyException(MethodCall expected, IEnumerable`1 setups, IEnumerable`1 actualCalls, Expression expression, Times times, Int32 callCount) in C:\projects\moq4\Source\Mock.cs:line 473
   at Moq.Mock.VerifyCalls(Mock targetMock, MethodCall expected, Expression expression, Times times) in C:\projects\moq4\Source\Mock.cs:line 452
   at Moq.Mock.Verify[T,TResult](Mock`1 mock, Expression`1 expression, Times times, String failMessage) in C:\projects\moq4\Source\Mock.cs:line 340
   at Moq.Mock`1.Verify[TResult](Expression`1 expression, Func`1 times) in C:\projects\moq4\Source\Mock.Generic.cs:line 508
   at CustomerServiceWeb.Services.Test.ServiceAgreements.ServiceAgreementUpdateProxyTest.<ServiceAgreementUpdateAddTest>d__8.MoveNext() in C:\SourceCode\FlexPricing\CustomerServiceWeb.Services.Test\ServiceAgreements\ServiceAgreementUpdateProxyTest.cs:line 115
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.ThreadOperations.ExecuteWithAbortSafety(Action action)

Any help what am I missing?
GeneralRe: Mocking a Service call in my Unit Tests Pin
Gerry Schmitz13-Feb-19 5:40
mveGerry Schmitz13-Feb-19 5:40 
QuestionNot able to read the Detail property of Exception, when it is shown in the Quick Watch Pin
simpledeveloper4-Feb-19 12:25
simpledeveloper4-Feb-19 12:25 
AnswerRe: Not able to read the Detail property of Exception, when it is shown in the Quick Watch Pin
Dave Kreskowiak4-Feb-19 14:04
mveDave Kreskowiak4-Feb-19 14:04 
GeneralRe: Not able to read the Detail property of Exception, when it is shown in the Quick Watch Pin
simpledeveloper8-Feb-19 7:15
simpledeveloper8-Feb-19 7:15 
GeneralRe: Not able to read the Detail property of Exception, when it is shown in the Quick Watch Pin
Dave Kreskowiak8-Feb-19 8:49
mveDave Kreskowiak8-Feb-19 8:49 
GeneralRe: Not able to read the Detail property of Exception, when it is shown in the Quick Watch Pin
simpledeveloper8-Feb-19 9:44
simpledeveloper8-Feb-19 9:44 
GeneralRe: Not able to read the Detail property of Exception, when it is shown in the Quick Watch Pin
Pete O'Hanlon8-Feb-19 10:37
mvePete O'Hanlon8-Feb-19 10:37 
GeneralRe: Not able to read the Detail property of Exception, when it is shown in the Quick Watch Pin
Dave Kreskowiak8-Feb-19 10:44
mveDave Kreskowiak8-Feb-19 10:44 
GeneralRe: Not able to read the Detail property of Exception, when it is shown in the Quick Watch Pin
simpledeveloper8-Feb-19 10:52
simpledeveloper8-Feb-19 10:52 
AnswerRe: Not able to read the Detail property of Exception, when it is shown in the Quick Watch Pin
Richard MacCutchan4-Feb-19 22:05
mveRichard MacCutchan4-Feb-19 22:05 
GeneralRe: Not able to read the Detail property of Exception, when it is shown in the Quick Watch Pin
simpledeveloper8-Feb-19 7:51
simpledeveloper8-Feb-19 7:51 
GeneralRe: Not able to read the Detail property of Exception, when it is shown in the Quick Watch Pin
Richard MacCutchan8-Feb-19 22:22
mveRichard MacCutchan8-Feb-19 22:22 
GeneralRe: Not able to read the Detail property of Exception, when it is shown in the Quick Watch Pin
simpledeveloper11-Feb-19 6:59
simpledeveloper11-Feb-19 6:59 
QuestionBindingSource Implementation in .net Win Forms Pin
rjto2-Jan-19 5:01
rjto2-Jan-19 5:01 
AnswerRe: BindingSource Implementation in .net Win Forms Pin
Pete O'Hanlon2-Jan-19 5:27
mvePete O'Hanlon2-Jan-19 5:27 
GeneralRe: BindingSource Implementation in .net Win Forms Pin
rjto2-Jan-19 5:36
rjto2-Jan-19 5:36 
GeneralRe: BindingSource Implementation in .net Win Forms Pin
mtoha16-Jan-19 16:19
professionalmtoha16-Jan-19 16:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.