« first day (2294 days earlier)      last day (2671 days later) » 
00:00 - 17:0017:00 - 00:00

5:07 PM
@KendallFrey I don't really understand the question.
 
@KendallFrey I'd say you'd want ReaderWriterLockSlim, but that's a thread-affine lock type
 
Hey guys, I'm using specflow and selenium to do some automation testing. I'm testing a hierarchy component which may contain parent / child nodes. My test is to ensure that the hierarchy displays parent and child nodes but of course in the real system this will depend on the database being present
and populated with the correct data
Is there a way to mock the database in automated test
Is it bad idea? How do I ensure that my tests are robust?
 
@MikeAsdf Yeah, I was looking at that, but wasn't sure if I could make it work.
 
@PrimeByDesign you can, they are not a bad idea.
https://kzhendev.wordpress.com/2014/01/07/an-introduction-to-database-unit-testing-with-tsqlt/ some reading that might be useful
 
@juanvan thanks but it seems like the link you sent me might be discussing unit tests not automation tests.
 
5:21 PM
we usually automate unit test (adding them to CI)
 
Hey
 
I'm using selenium with specflow inside mstest but it opens the browser. There doesn't appear to be a way to mock parts of the system
as I am testing against a running server
 
Need some help with common table expression. it has bugs but i couldnt find it :\
 
"common table expression"
This room's area of expertise is not SQL but maybe we can help
"It has bugs"
If you say so
"i couldnt find it"
Well neither can we because you've given us no indication of what it should do and what it's doing instead
 
Found the problem and fixed it the moment i said hi
 
5:35 PM
+14
 
hey guys
I know it's the wrong chat, but does anyone know the difference between Malloc and malloc? IS there a difference?
 
@mmf1102 one's capitalized
 
sorry that seems bitter. It was meant as a joke :)
 
One is an object the other a Class?
 
VS's autofill says malloc accepts a size and Malloc accepts a type
@juanvan that... makes a lot of sense
 
5:40 PM
If it's the malloc I know, it's neither an object nor a class
 
wait hold on it is neither an object nor a class
it's just a function
 
I know malloc, I worked with malloc. You, sir, are no malloc.
 
Ah I got it
Malloc(type, n) is a shortcut for (type pointer)malloc(n*sizeof(type))
 
@KendallFrey
 
how do you cancel formatting?
 
5:44 PM
@SteveG where
 
in the stackoverflow chat
Is it just doubling the character?
*Test*
 
what
 
I don't know why I hadn't thought of escape characters XD
 
200 nobody star this
 
@SteveG yeah
@SteveG ⭐️ ⭐️ ⭐️ ⭐️ ⭐️
 
5:46 PM
@mikeTheLiar ????
 
5/7 perfect
 
@SteveG ❓ ❓ ❓ ⁉️
 
¿
¿
168
 
💩
 
T͑̾̚o͖̰͎̠̖̗͔̿̒̌ͨ͛͌̒ ̜̙̹̩ͧ͆ͧ̔ǐ̞̲ͮ̌n̗͓̐ͨͩv̞̗͖̫̖̬͍̐o͎̙̪̓ͨ̑ͦ́̿ͦḱ̫̪̥̱̟e̬̳͙̫͚̅ͦ̽ ̱̱̮̜̯̘ͩͣ͋͑͂̄ṭ͇̦̉͆̒h̞ͦ̄ͣ̒ë͆̎ ̳̲h̯̜̎ͧͮì̑͐̀̿̾v̩͔̈e̘̫̺ͯ̐̓͐̎ͅ-̫̳̔̈́ͥ́͛̽m̳̮̭̗̮̗i͖̗̫͕ͅn̞ͅḓ̩͈͎̙̖̎̂̈́̍ͦͥͅ ̜̹̹̣̱͒̌ṛ͕̟̞̝͚e̹̮̞̺̖̟p̯͍̎ͅr̮ͮe͙̜̻̘̺ͫ̔s̫̠͖̘͗ͩ̑ͬ̾͐ͩe̥̰̻͍͌͊̎ͩ̆̾̏n̦̦̝͕̈̒̇͛̑̓t̥ͫ͌̊̏ͫ͆̂i̦̊̉nͤͩͧg̘̈ͨ ̠̳͔̭̠̜̾ͅc̔ḧ̹̪̬̫͚̥́a̫͉̼̞̣̓̌̔̾ỏ̝ͬͨs͚̺̜͇̥̬ͩ̋.ͬ̅
̹̈́̏͆ͧ̆I͊ͫ͊̿͋nͩ̎v͖̪͍̞̦̓͌̂o̮̖ͧ̆ͪ̈́́k̠̝͉͍͕͙̩̉̋i̙͈̘͙̝̫͇ͨ̍͋ͯn̯̰̍̾ͩ͊̒̿ͤg̟̘̦̼͖ͩ̊ͣ͂ͩͤͯ ̌̔̆̇t̗̰̹̗̃̇͋ͣh̻̩̲͓̙͋ͣ̊ͩ̿͊̚è̗̥͕͕̫̥̞̓̊ͦ̋ ̱̗̟͎̾ͭ̿͒̓f̥̖̳̖́ͪͧͫ̈́͋̓ͅe̊e̐̍́̋̍ͣl̲̾ͦ͌̏ͅi͉̪͔̓ͬ̓ng͔̲̘̫̐̾̓ ̜̮͈̩̬ͅoͫ̆̾f̗͕̩͐ͅ ̌̆͑c͙͚̫̩̪̉ͨ̏̈́̈̐h̖̱̲̄ͫͭ̑a̞͚̬̾̄os͕̦͕̬̫̗͖̍.̳̭͚̲̯͓ͫ̊̄͐ͯ
@KendallFrey I like how people debate whether that's a pile of poop or ice cream but then unicode-table.com/en/1F4A9
ice cream is the alternative facts
 
5:52 PM
It's never been anything but poo
 
I've heard people arguing it's ice cream
 
🍦
 
why the fuck would ice cream have eyes
 
Why would poop have eyes?
 
i had to really push, ok
 
6:00 PM
did you shit undigested potatoes? I hear they're quite the lookers
 
I can't believe you've done this.
 
seeing is believing
 
Dumb question, I have an entity with an assortment of data types. Including a decimal?. With it being generic and pulling the data from a file, what would be the proper way to cast via reflection?
I find this isn't helping me:

typeof(TEntity).GetPropert(table.Values.ElementAt(column))
     .SetValue(instance, Convert.ChangeType(columns[column], typeof(TEntity).GetProperty(table.Values.ElementAt(column)).PropertyType), null);
 
6:15 PM
What do you mean the entity has an assortment of data types? Doesn't a generic represent any type?
 
It is an object, with multiple properties.
 
ah
I'm afraid I don't know enough about generics to be of much help here
I haven't used them myself too frequently
 
public class Example
{
   public DateTime Date { get; set; }
   public decimal? Number { get; set; }
   public string Name { get; set; }
}

For instance.
 
So you're trying to get the type of one of its members?
 
6:31 PM
No, I want to set a string from a document to the object as the specified type of the property.
 
So let's say the string is "10", you want to store that as Number in your Example class?
 
Yeah.
 
I have no idea
sorry
 
 
1 hour later…
8:00 PM
Hi All, I have a hard time understanding this code.
http://stackoverflow.com/questions/1202935/convert-rows-from-a-data-reader-into-typed-results
It would be great if someone could explain more on this?
 
@Rohith The person is basically looking for an ORM. Something that will take the tabular data, then return each row as a POCO.
 
Having a little trouble understanding the lock statement, if anyone would care to answer a few questions?
 
??
 
@gre
 
Yes?
 
8:03 PM
@Greg, What I didn't understand is this piece
using (var reader = YourLibraryFunction())
{
while (reader.Read())
{
yield return Employee.Create(reader);
}
}
 
@Rohith That line, would be calling the mapper function. Since it is IEnumerable, they make use of the yield return to create said object.
 
If I am locking the same object in multiple parts of my code, will locking that object in one method prevent any other methods from running until the lock is released?
This comment has me confused: stackoverflow.com/questions/15154110/…
 
@jhmckimm Yes, you should look up mutex.
I think it is a mutex.
 
yield return is a special type of return. Read it as, "For each item in the datareader, add it to the return value and return the whole list."
 
@TylerStahlhuth Yes, that is correct.
 
8:05 PM
for eg. I can assume that YourLibraryFunction() is dbcommand.executeReader(). right?
 
@Rohith Perhaps.
 
That's safe to assume
basically whatever gets you the datareader
 
Dapper would do:

dbConnection.Query<SampleObject>(query, parameters);

But would build your object.
 
is it common to have DataAccessLayer IEnumerate then have DataObjectLayer ToList the result?
 
@TylerStahlhuth You familiar with Nullable and Generic?
 
8:08 PM
What specifically?
 
I have a property within a poco. When I pull from a text document, it is a string. I need to cast to a decimal? while adhering to the other types.
 
Explain "adhering to the other types."
Could it possibly be an int or something like that?
Or are you sure it's a decimal
Or at least that you want it to be a decimal
 
public class SampleObject
{
     public DateTime Date { get; set; }
     public decimal? Number { get; set; }
     public string Name { get; set; }
}
 
Are you looking for a generic method to basically go through all the properties in the object, find a matching type/name, then cast to that type and store it in the property?
Or are you okay with mapping manually?
 
    When you call:

    var instance = (TEntity)Activator.CreateInstance(typeof(TEntity));
    PropertyInfo property = typeof(TEntity).GetProperty(table.Values.ElementAt(column));
property.SetValue(instance, Convert.ChangeType(columns[column], property.PropertyType), null);
Generic method.
But obviously the decimal? will completely destroy Convert.ChangeType.
 
8:15 PM
Are you wanting a method that does that code as a generic? None of those methods in the above code are generics.
You could do Nullable<decimal>
 
Well, I really want to know how to cast for Nullable types.
 
Thanks @Greg and @TylerStahlhuth
 
If the property is decimal? I think that would still work
 
@TylerStahlhuth Doesn't, says can't coerce string to decimal?
I was thinking I might need to make use of MakeGenericTypeDefinition.
But not sure.
 
Do a Decimal.TryParse(str, out dec) first.
 
8:19 PM
I think I need:

     property.SetValue(model,Convert.ChangeType(control.Value, property.PropertyType.GetGenericArguments()[0]),null);
 
He can't, he doesn't know the class yet
 
Something along that.
 
187
Q: Convert.ChangeType() fails on Nullable Types

iboenoI want to convert a string to an object property value, whose name I have as a string. I am trying to do this like so: string modelProperty = "Some Property Name"; string value = "SomeValue"; var property = entity.GetType().GetProperty(modelProperty); if (property != null) { property.SetValu...

 
Doesn't know the class yet?
 
Yeah, Reflection.
 
8:22 PM
So he's trying to figure the class out from the string? That's impossible to narrow down.
Try to parse it with int, double, float, decimal, whatever. Move down the list until it returns true for one of them.
Or am I missing something else?
 
He has a string something in the way of "propertyName|value"
He is going through the object, getting all the properties, and setting the value to that equal of the value part.
Basically, he knows the name, not the type.
 
Yes, exactly.
 
I still don't see how cycling through all the TryParse()s for each would not work? It tells you whether or not the information in the string can be your type or not. What am I misunderstanding?
 
A class could have two ints
 
Why does this give me 10 lines with "Hello, world! #10"?

for(int i = 0; i < 10; i++) {

                taskQueue.AddTask(() => {

                    Console.WriteLine("Hello, world! #" + i);
                });
            }
 
8:28 PM
Do you ever execute all the tasks?
Ohhhh
nvm
 
Yes. They're processed on another thread as soon as they're added.
 
Save 'i' to a variable outside the task. Pass that variable to the task.
 
Right, you are passing in the
exactly
What he said
 
@Meloviz That is a lot of painful manual code, to something you're attempting to automate.
 
That got fixed in later versions, I think, but I don't remember when.
True, it is.
 
8:30 PM
taskQueue.AddTask accepts an action. I can't pass parameters.
 
When you create an action you can pass it a value
 
I mean like this:

for(int i = 0; i < 10; i++) {
    int x = i;
                taskQueue.AddTask(() => {

                    Console.WriteLine("Hello, world! #" + x);
                });
            }
 
...what the heck.
Why does that change anything?
 
I suppose more accurately, I could have said "Use the variable in the task's execution."
 
We talking closures all up in this shit?
 
8:32 PM
A new variable is created each time the loop executes
 
Because it's not actually passing in i at its index. I don't know all the inner workings of it, but that's the way it is in whatever version you're targeting.
 
Then it uses that variable
Think about pass by reference
 
ReSharper will warn you of shit like that
 
Yeah.
 
Suggesting you extract it into an isolated variable
 
8:33 PM
I feel like I'm Jon Snow now.
I've been using C# for a while and haven't ever experienced anything like that.
 
I felt quite perplexed when I first encountered that, too. Very frustrating.
 
Well, that chick died so jokes on her.
Yeah, I 'member my first time with that as well
 
I quite liked Ygritte as well. :(
 
especially infuriating with an int
You'd think it would get passed by value
 
something something shot through the heart and jon's to blame
 
8:36 PM
Yeah, I even tried i.ToString() because I'm a genius.
 
Anyone know much about MVC? Or is that answer in another castle?
 
I have knowledge but probably can't quickly answer anything difficult
 
Well, I am trying to think of a way to basically add a class to every view that contains information specific to the view without littering the cshtml files with class initializers.
It's for a help button on the page.
The help could be long, so I don't want to initialize it every view.
 
? the cshtml has class initializes?
 
Otherwise, I'll end up with tons of strings in every view. Which would suck.
Yeah, it contains the Model, Helpers, Viewbag and the like
 
8:45 PM
class references
@using Project.Something..
 
Personally I am using a WebViewPage in System.Web.Mvc
I am pretty sure that isn't the default
 
You want to add some other data to the page that is not in the Model
or should not be part of the model
brb
 
Correct, it's more about the page rather than in the page if that makes sense
 
9:34 PM
should this page be a partial page?
 
9:50 PM
It will be a partial page with a link that opens a window with information specific to the current view. I am guessing I could store all the data in a dictionary by view name.
 
Howdy.
Can someone confirm that in a database markup file (DBML), the Name attribute of the Database tag and ConnectionString attribute of the Connection tag are completely ignored if the Connection tag contains a SettingObjectName and SettingPropertyName pointing to the web.config?
 
10:11 PM
So apparently "" doesn't translate to a null. So when I manually force the value of null to be passed to a typeof(Nullable<>) it doesn't work. Still errors.
 
@Greg What? strings are nullable.
But "" is not null. It's empty
 
"" is an empty string.
 
10:26 PM
What if you do
 string str = "";
string msg = str ?? "Was it Null?";
 
@juanvan msg is an empty string
 
@juanvan So the answer is that msg would contain "" at the end of your code.
What are you trying to do?
 
was seeing for gregg
making a sce for him to play with
 
11:31 PM
Hey all , I'm Sorry but i have another Question :

Can i initialize a Class constructor in different ways depends on what object uses it ?
 
11:56 PM
@ItayZaguri A constructor can be thought of as a method (that just has some syntax restrictions on it)
A method can have code in it that has different behavior based on arguments.
Are you asking "does C# have if statements?"?
 
@MikeAsdf yeah i know, I'll use my case : I have an abstarct Class Vehicle which has an Object from a class Engine ( which has Fuel\Electric Classes derived from it)
Vehicle Class has 2 classes Derived from it - Car\Bike. each one can be either Electric or Fuel-using
 
00:00 - 17:0017:00 - 00:00

« first day (2294 days earlier)      last day (2671 days later) »