|
Just use MS Power BI for the desktop and be done with it.
Power BI Desktop | Microsoft Power BI
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
|
I sort of got that from his last line. Just wanted to irritate him by stealing his soapbox.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I am building an application in WPF for the first time. The application is intended to track employees who are hired by the company, track the hire type (e.g…assignment category…full time, part time, seasonal, intern). In addition, it will track which department to which an employee is assigned during their tenure with the company. Some employees are exposed to several different departments while employed in order to more fully round out their training or due to work loads.
The backend for this application is built in SQL Server and contains three tables. They are company employees, company departments, and assignment categories. Each obviously has its own primary key.
I have created a datagrid that, via Linq to SQL Classes, displays data from the company employees table. Each of the columns in the datagrid is a DataGridTextColumn except for one which is a DataGridComboBoxColumn. The DataGridTextColumn’s work fine. However, I cannot seem to get the binding correct. The column appears in the datagrid and is a working combobox. The issue is that I cannot find how to populate the combox with values from which the end user will select. This combobox will allow the end user to choose which under which assignment category an employee has been hired.
As an end result, this application will be used by the company owner to keep track of the number of employees that he has on hand and show who will be leaving each month due to being a seasonal worker or an intern.
Below is the code behind and the xaml. Please note that I have spent several days now researching this topic and cannot find anything that I can make work. I am confident that this is because I am just learning xaml and c#.
Can someone help me understand what I am doing wrong, please?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace staff_scheduling_tool.views
{
public partial class employees_new_employee : UserControl
{
assignment_typeDataContext dc = new assignment_typeDataContext(Properties.Settings.Default.db_employee_scheduling_applicationConnectionString);
public employees_new_employee()
{
InitializeComponent();
if (dc.DatabaseExists()) datagrid_search_results.ItemsSource = dc.companyemployees;
}
private void Save_changes_Click(object sender, RoutedEventArgs e)
{
dc.SubmitChanges();
}
}
}
<DataGrid Name="datagrid_search_results" Margin="10,25" Width="1400" Height="350" AlternatingRowBackground="LightGreen" GridLinesVisibility="None" SelectionUnit="Cell" BorderBrush="Transparent" BorderThickness="0" Background="Transparent" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding employee_id}" Width="Auto" Header=" Employee ID" />
<DataGridTextColumn Binding="{Binding last_name}" Width="Auto" Header=" Last Name" SortDirection="Ascending" />
<DataGridTextColumn Binding="{Binding first_name}" Width="Auto" Header=" First Name"/>
<DataGridTextColumn Binding="{Binding middle_name}" Width="Auto" Header=" Middle Name"/>
<DataGridTextColumn Binding="{Binding company_email}" Width="Auto" Header=" Company Email"/>
<DataGridComboBoxColumn Width="Auto" Header="Assignment Category" />
<DataGridTextColumn Binding="{Binding department_assignment_begin_date, StringFormat=d}" Width="Auto" Header=" Begin Date"/>
<DataGridTextColumn Binding="{Binding department_assignment_end_date, StringFormat=d}" Width="Auto" Header=" End Date"/>
</DataGrid.Columns>
</DataGrid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="45"/>
</Grid.RowDefinitions>
<Button Name="save_changes" Content="Save Updates" Click="Save_changes_Click" Grid.Row="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="250" FontFamily="Sitka Banner" FontSize="24" FontStyle="Italic" FontWeight="ExtraBold"/>
</Grid>
modified 28-Feb-19 17:42pm.
|
|
|
|
|
|
So I was able to get the code below, but the combo box still will not populate. Can someone help me understand what I am still doing wrong, please?
<DataGrid ItemsSource="{Binding db_employee_scheduling_application}"
Name="datagrid_search_results" Margin="10,25" Width="1400"
Height="350" AlternatingRowBackground="LightGreen" GridLinesVisibility="None"
SelectionUnit="Cell" BorderBrush="Transparent" BorderThickness="0"
Background="Transparent" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding employee_id}" Width="Auto" Header=" Employee ID" />
<DataGridTextColumn Binding="{Binding last_name}" Width="Auto" Header=" Last Name" SortDirection="Ascending" />
<DataGridTextColumn Binding="{Binding first_name}" Width="Auto" Header=" First Name"/>
<DataGridTextColumn Binding="{Binding middle_name}" Width="Auto" Header=" Middle Name"/>
<DataGridTextColumn Binding="{Binding company_email}" Width="Auto" Header=" Company Email" />
<DataGridComboBoxColumn Width="Auto" Header="Assignment Category"
ItemsSource="{Binding assignment categories}"
DisplayMemberPath="assignment category name"
SelectedValuePath="assignment category id"
SelectedValueBinding="{Binding assignment category name}"/>
<DataGridTextColumn Binding="{Binding department_assignment_begin_date, StringFormat=d}" Width="Auto" Header=" Begin Date"/>
<DataGridTextColumn Binding="{Binding department_assignment_end_date, StringFormat=d}" Width="Auto" Header=" End Date"/>
</DataGrid.Columns>
</DataGrid>
|
|
|
|
|
Hey Gerry,
I appreciate your responses. However when I tried implementing your advice and the resulting combo box wouldn't even open. That is not to say that you gave bad advice, but to say that I am in need of more detailed instructions, please.
|
|
|
|
|
I have try DataGridComboBoxColumn but it not works.
you can try
DataGridTemplateColumn
such as
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Types}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
if you still want to use DataGridComboBoxColumn see msdn demo for more details
|
|
|
|
|
Hello everybody,
i'm writing here because i've a strange problem and i'd like to know if my idea is doable!!
Everyday I use a program for working that have not been made by me. This program is made by a console with different button and functions that starts other Windows. These Windows are not child window but are processes in fact in my task manager there are a lot of running processes.
The software house who developed this old program allow me to use an SDK/API in Visual Studio for building my own programs.
The original program works using the same DLL i have to import to develop my owns program but it has never been converted in .NET program and it has always been adapted with different tricks.
My main problem is that to have my own program working i always have to use some tricks like pre/post compilation events and above all, i CAN'T compile with latest .NET Framework but i've to use maximum 3.5.
I'd like to insert in my own program dropbox or google drive API but the NuGet packet doesn't support an application compiled with 3.5 Framework and it only wants the latest one.
So, i thought to develop my own class library that import the software house DLL and who is compiled with .NET Framwork 3.5. In my own program i won't add references to the software house DLL but i will reference to my own class library. In this way i could be able to compile my own application with latest Framework bypassing the limit of the software house DLL. The aim of my new Class Libraries si to work like a "bridge" bewteen my program and the older DLL developed by the software house.
What do you think about my idea?
I also used Telerik JustDecompile to watch inside the old DLL and they don't seem to be very complex. I could also post a screen shot of decompiled code but i don't find the function to do it!!!
|
|
|
|
|
Yes, it's called a COM server and is "doable".
COM Server Development using .NET
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Thank you Gerry,
i'll study your advice and i'll try to use it!!!
|
|
|
|
|
This is mainly a curiosity question.
I've seen some pretty cool examples written in MSIL, but I've been able to decompile those examples back C#, so it is unclear why MSIL would be a better choice beyond personal preference.
Are there times when C# and other .net Languages simply can't solve a problem, but can be solved in MSIL (ie a workaround\hack), or maybe sometimes coding in MSIL is more efficient when compared to the compiler? Which would not make too much sense if the code can be decompiled into C# and other .net languages.
|
|
|
|
|
|
HI Freinds,
In our Project we are changing some methods synchronous to asynchronous.There is one situation iam using task.run concept we have global error log where we can read entire structure of the error.when i apply task.run global error log is broken.
Here is my code:
try{
Task.Run(() =>
{
SendMailForGSSCQuotes(mDBEntity.QUOTATIONNUMBER.ToString(), Convert.ToInt32(mDBEntity.ThresholdQty), Convert.ToInt32(mDBEntity.ISHAZARDOUSCARGO), Convert.ToInt32(mDBEntity.HASMISSINGCHARGES));
}).ConfigureAwait(false);
}
catch(Exception ex){
LogErrorAsync("api/Quotation", "SendMail", ex.Message.ToString(), ex.StackTrace.ToString());
}
in SendMailForGSSCQuotes intentionally throwing error to see how the global error log works.
protected void LogErrorAsync(string controller, string action, string message, string stacktrace, string user = "")
{
QuotationDBFactory mFactory = new QuotationDBFactory();
mFactory.InsertErrorLog(
user,
controller,
action,
message,
stacktrace
);
SendEmailAysnc(stacktrace, message).ConfigureAwait(false);
}
internal async Task<bool> SendEmailAysnc(string st, string ex)
{
try
{
var Content = string.Empty;
if (this.ActionContext.Request.Method.ToString() == "POST")
{
var d = new StreamReader(await Task.Run(() => this.ActionContext.Request.Content.ReadAsStreamAsync().Result).ConfigureAwait(true));
d.BaseStream.Seek(0, SeekOrigin.Begin);
Content = d.ReadToEnd();
}
var hostdata = ((System.Web.HttpRequestWrapper)this.RequestContext.GetType().Assembly.GetType("System.Web.Http.WebHost.WebHostHttpRequestContext").GetProperty("WebRequest").GetMethod.Invoke(this.RequestContext, null));
var exdata = new ExceptionEmailDto()
{
ActionMethod = this.ActionContext.Request.Method.ToString(),
AppUrl = System.Configuration.ConfigurationManager.AppSettings["APPURL"],
Error = ex,
Headers = this.ActionContext.Request.Headers.ToString(),
ServerName = System.Configuration.ConfigurationManager.AppSettings["ServerName"],
StackTrace = st,
Url = this.ActionContext.Request.RequestUri.ToString(),
UserAgent = hostdata.UserAgent == null ? string.Empty : hostdata.UserAgent.ToString(),
UserHostAddress = hostdata.UserHostAddress == null ? string.Empty : hostdata.UserHostAddress.ToString(),
UserHostName = hostdata.UserHostName == null ? string.Empty : hostdata.UserHostName.ToString(),
UTC = DateTime.UtcNow.ToString(),
Content = Content,
ServerVariables = hostdata.ServerVariables == null ? "undefined" : hostdata.ServerVariables.ToString()
};
FOCiS.SSP.Web.UI.Controllers.APIDynamicClass.SendExceptionEmailV2(
exdata
);
}
catch (Exception exc)
{
FOCiS.SSP.Web.UI.Controllers.APIDynamicClass.SendExceptionEmail(this.ActionContext.Request.Method.ToString(),
exc.Message.ToString(), exc.StackTrace.ToString()
);
return false;
}
return true;
}
Getting error here
var d = new StreamReader(await Task.Run(() => this.ActionContext.Request.Content.ReadAsStreamAsync().Result).ConfigureAwait(true));
Error:
Cannot access a disposed object.
Object name: 'System.Web.Http.WebHost.HttpControllerHandler+LazyStreamContent'.
I tried so many ways if i remove Task.Run its working fine.
Thanks
|
|
|
|
|
Why do you have a task.run inside an sync method when this would be perfectly OK and works as you say:
var d = new StreamReader(await this.ActionContext.Request.Content.ReadAsStreamAsync());
|
|
|
|
|
I tried as you said
var d = new StreamReader(await this.ActionContext.Request.Content.ReadAsStreamAsync());
Quote Selected Text
Still same exception is throwing i guess some where problem with Task
|
|
|
|
|
The formatting is a bit all over the place so it's hard to read, but this should also be async:
protected async Task LogErrorAsync(string controller, string action, string message, string stacktrace, string user = "")
{
QuotationDBFactory mFactory = new QuotationDBFactory();
mFactory.InsertErrorLog(
user,
controller,
action,
message,
stacktrace
);
await SendEmailAysnc(stacktrace, message);
}
and then:
try{
Task.Run(() =>
{
SendMailForGSSCQuotes(mDBEntity.QUOTATIONNUMBER.ToString(), Convert.ToInt32(mDBEntity.ThresholdQty), Convert.ToInt32(mDBEntity.ISHAZARDOUSCARGO), Convert.ToInt32(mDBEntity.HASMISSINGCHARGES));
}).ConfigureAwait(false);
}
catch(Exception ex){
Task.Run(() =>
{
LogErrorAsync("api/Quotation", "SendMail", ex.Message.ToString(), ex.StackTrace.ToString());
});
}
|
|
|
|
|
I tried the same as you mention still no luck.Same error throwing
|
|
|
|
|
Why we choose Task.Run to render the UI First then we will run remaining methods.here chosse task.run its working fine as per requirement when coming back to global error its broken as my guess the object is dispose when UI as render so no where to run the
ReadAsStreamAsync
|
|
|
|
|
I am very new to coding and had to write a code for my college project referring to a YouTube video. So far everything I have written is fine but only one error seems to repeat itself which is: 'Statement is not valid n a namespace'
Please help..
Option Explicit On
Dim BUFFERSS
Private Declare Sub Sleep Lib "kernel132" (ByVal dwMilliseconds As Long)
Dim message As Integer<small><big><pre>
Dim search As String
Dim strTest As String
Dim user1 As Integer
Dim user2 As Integer
Dim time1 As Integer
Dim time2 As Integer
Dim mins As Integer
Dim secs As Integer
Dim teacherflag As Integer
Dim sflag1 As Integer ' Student 1 flag
Dim sflag2 As Integer ' Student 2 flag
Dim sflag3 As Integer ' Student 3 flag
Dim msending As Integer ' message sending flag
Dim absent1 As Integer
Dim absent2 As Integer
Dim absent3 As Integer
Dim absentflag As Integer
Dim flag1 As Integer
Dim flag2 As Integer
Dim flag3 As Integer
Dim counter As Integer
Private Sub Form_Load()
mins = 0
Timer3.Enabled = False
teacherflag = 0
sflag1 = 0
sflag2 = 0
sflag3 = 0
msending = 0
absent1 = 0
absent2 = 0
absent3 = 0
absentflag = 0
flag1 = 0
flag2 = 0
flag3 = 0
PerformanceCounter = 0
'MSComm1.Settings = "9600,n,8,1" 'Change this with the Baud rate of your modem (The one that you use with the Hyper terminal)
'MSComm1.CommPort = 10
'MSComm1.PortOpen = True
With MSComm1
.CommPort = 3
.Settings = "9600,N,8,1"
.Handshaking = comRTS
.RTSEnable = True
.DTREnable = True
.Rthreshold = 1
.Sthreshold = 1
.InputMode = comInputModeText
.InputLen = 0
.PortOpen = True 'Must be the last
End With
End Sub
Private Sub Timer1_Timer()
txtrec.Text = MSComm1.Input
SearchDirectionHint = txtrec.Text
If (InStr(search, "teacher") And (teacherflag = 0)) Then ' when the teacher will swipe the RFID card word teacher will be
Check3.Value = 1
Timer3.Enabled = True 'timer3 is used for timing mins and secs
teacherflag = 1
Timer4.Enabled = True
End If
If (InStr(search, "stu1") And (sflag1 = 0) And mins < 6) Then 'then the student 1 will be marked present
Check4.Value = 1
sflag1 = 1
End If
If (InStr(search, "stu2") And (sflag1 = 0) And mins < 6) Then 'then the student 2 will be marked present
Check5.Value = 1
sflag2 = 1
End If
If (InStr(search, "stu3") And (sflag1 = 0) And mins < 6) Then 'then the student 3 will be marked present
Check6.Value = 1
sflag3 = 1
End If
End Sub
Private Sub Timer2_Timer()
Label5.Caption = TimeOfDay
End Sub
Private Sub Timer3_Timer()
secs = secs + 1
Label7.Caption = Secs
If secs > 59 Then
secs = 0
mins = mins + 1
Label3.Caption = mins
End If
End Sub
Private Sub Timer4_Timer()
'sending message to students to let them know that the teacher has arrived.
'in the controller program each and every user will have its own message sending function in which his number will be specified
PerformanceCounter = PerformanceCounter + 1
Label3.Caption = PerformanceCounter
If ((teacherflag = 1) And ((PerformanceCounter > 10) And (PerformanceCounter < 20)) And (Check8.Value = 0)) Then
Check8.Value = 1
End If
If ((teacherflag = 1) And ((PerformanceCounter > 30) And (PerformanceCounter < 40)) And (Check9.Value = 0)) Then
Check9.Value = 1
End If
If ((teacherflag = 1) And ((PerformanceCounter > 50) And (PerformanceCounter < 60)) And (Check10.Value = 0)) Then
Check10.Value = 1
End If
If ((teacherflag = 1) And ((PerformanceCounter > 90) And (PerformanceCounter < 120)) And (Check12.Value = 0)) Then 'this when checked means all message sent
Check12.Value = 1
End If
'check box for parents messages
If ((Check12.Value = 1) And ((PerformanceCounter > 300) And (PerformanceCounter < 320) And (check4.Value = 0))) Then 'This when checked means all message
Check13.Value = 1
End If
If ((Check12.Value = 1) And ((PerformanceCounter > 330) And (PerformanceCounter < 350) And (check5.Value = 0))) Then 'This when checked means all message
Check14.Value = 1
End If
If ((Check12.Value = 1) And ((PerformanceCounter > 370) And (PerformanceCounter < 380) And (check6.Value = 0))) Then 'This when checked means all message
Check15.Value = 1
End If
If ((Check12.Value = 1) And ((PerformanceCounter > 390) And (PerformanceCounter < 400) And (check7.Value = 0))) Then 'This when checked means all message
Check16.Value = 1
End If
'**************************************************************************
If ((Check8.Value = 1) And (flag1 = 0)) Then
MSComm1.Output = "a"
flag1 = 1
End If
If ((Check9.Value = 1) And (flag2 = 0)) Then
MSComm1.Output = "b"
flag2 = 1
End If
If ((Check10.Value = 1) And (flag3 = 0)) Then
MSComm1.Output = "c"
flag3 = 1
End If
'message sending to their parents
If ((Check13.Value = 1) And (Absent1 = 0)) Then
MSComm1.Output = "l"
Absent1 = 1
End If
If ((Check14.Value = 1) And (Absent2 = 0)) Then
MSComm1.Output = "m"
Absent2 = 1
End If
If ((Check15.Value = 1) And (Absent3 = 0)) Then
MSComm1.Output = "n"
Absent = 1
End If
End Sub
Sameer
|
|
|
|
|
It looks like you've chosen a really bad video to follow. That looks more like VB6 code than VB.NET.
Assuming you're actually using VB.NET, try some VB.NET tutorials instead:
Visual Basic development with Visual Studio - Visual Studio | Microsoft Docs[^]
The obvious problem is that you're putting variables and functions directly within the code file. In VB.NET, they need to be within a Class or Module . Looking at the code you've posted, it needs to be within the Class that defines your form.
NB: If you're actually using VB6, then don't! VB6 has been effectively "dead" for almost 20 years now.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks a lot!
And yes, you are right I am using VB.NET.
|
|
|
|
|
Hi,
I am writing unit tests for my application, I have a Service call which I wanna mock, the my method takes list of some type and converts that type into another type of objects then calls another back-end Service which we have only Proxy class but don't know much about it, for each item in the list - means for each item in the list we pass, it will be converted and then passed to that black-box service that we don't know anything about, our method returns nothing, I mean this methods is void method.
If Service call fails for any one item in the list, our our method throws Exception aborts calls to all the remaining items, that's all it does, its simple for implementation but for writing Unit Tests I am having problems.
What I have to check is, weather the conversion of the list of type items that we are passing is done properly or not, and there no response, so I have to mock it, I am trying, but the problem is, how am I going to check for all the items, since the scope of those items that are converted would be within that method call. Its just breaking my head, and I don't want to repeat the mock calls more than what it needs to be. Any help would be greatly greatly helpful - thanks in advance.
My Test method that I am trying:
[TestMethod]
public async Task ServiceAgreementUpdateAddTest()
{
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>>>())).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));
}
My Method is as below:
public async Task ServiceAgreementCharacteristicAsync(List<ServiceAgreementCharacteristicRequest> serviceAgreementCharacteristicRequests)
{
foreach (var item in serviceAgreementCharacteristicRequests)
{
var request = new C1ServiceAgreementUpdateRequest
{
C1ServiceAgreementUpdate = new C1ServiceAgreementUpdate
{
serviceAgreement = item.ServiceAgreementId,
saChar = new[]
{
new C1ServiceAgreementUpdateSaChar
{
action = MapActionType(item.ActionType),
actionSpecified = true,
serviceAgreement11 = item.ServiceAgreementId,
characteristicType3 = item.CharacteristicType,
characteristicValue2 = item.CharacteristicValue,
effectiveDate6 = DateTime.Now,
effectiveDate6Specified = true,
searchCharacteristicValue = SearchCharacteristicValue
}
}
}
};
await this._serviceWrapper.UseServiceAsync((ATC1ServiceAgreementUpdatePortType service) => service.C1ServiceAgreementUpdateAsync(request)).ConfigureAwait(false);
}
}
private listAction MapActionType(RequestAction requestAction)
{
var actionType = listAction.add;
switch (requestAction)
{
case RequestAction.ADD:
break;
case RequestAction.UPDATE:
actionType = listAction.update;
break;
case RequestAction.DELETE:
actionType = listAction.delete;
break;
default:
throw new ArgumentException($"CustomerServiceWeb.Services.ServiceAgreements.ServiceAgreementUpdateProxy.MapActionType: Unmapped CustomerServiceWeb.Domain.Services.Common.RequestAction value: {requestAction.ToString()}");
}
return actionType;
}
modified 8-Feb-19 15:56pm.
|
|
|
|
|
You "mock" the service call, capture the "send" (as XML or whatever), print it or display it, compare it to an "expected output".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
But I am passing args as list to the method that I am going to test but that method loops through each individual item of the list and converts it then calls the service by sending that converted object as an argument.
The problem is how am I going to know the converted object when it is within the scope of the method that I am testing.
You kind of gave me definitely some hint, maybe I am not able to pick it up very well, any code snippet or example link etc, anything helps my friend.
It seems like it is difficult to test these types of Black-box methods (which return void) - and thanks a lot for the support my friend.
One of my Colleague has provided me the below method to do it:
public async Task ServiceAgreementUpdateAddTest()
{
var expectedServiceRequest1 = new C1ServiceAgreementUpdateRequest();
var expectedServiceRequest2 = new C1ServiceAgreementUpdateRequest();
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))));
this._serviceAgreementUdateSvc.Verify(svc => svc.C1ServiceAgreementUpdateAsync(It.Is<C1ServiceAgreementUpdateRequest>(x => x.Equals(expectedServiceRequest2))));
}
But when I tried to see by putting the breakpoint there, the inside values or attributes of the expectedServiceRequest1 and expectedServiceRequest2 are coming null, I am not understanding how it is working and what is the fix for it. Any help please? Am I doing any mistake or my colleague has not provided me complete code, its spinning my head - need some help please.
modified 8-Feb-19 18:16pm.
|
|
|
|
|