|
fleshweasel posted:Get just the capture group. Groups have automatic number identifiers or can be named. Google knows. Also, write \d{4} not \d\d\d\d.
|
# ? Mar 7, 2015 01:14 |
|
|
# ? Jun 6, 2024 10:06 |
|
UberJumper posted:So apparently after writing C# unit tests for half a week. I have apparently just inherited all responsibilities as lead test developer. The company is small (~20 people), and honestly even after saying "This is a bad idea" and i don't know anything about being lead test developer, they still put me in this position. Read Roy Osherove's book The Art of Unit Testing. That's first and foremost. IMO there should be no such thing as a "test developer". Everyone should be writing unit tests while they write their code. The tests should be considered first-class citizens and live in the same solution as the code they're testing. If you're doing true unit testing, the VS test runner should be configured to run tests after every compilation -- this goes for everyone. If a test breaks, fix the test right away. It doesn't matter who wrote the test that's failing. Testing is all about shortening the feedback loop and identifying and correcting bugs faster. It also helps inform the design of your application -- something that's hard to test is probably badly designed and needs to be refactored. Siloing "developer" and "test developer" is counter to the entire idea of shortening the feedback loop and informing design. The fastest way to have a failed automated testing adoption is to let the tests be second-class citizens that only one or two people thinks about or maintains. The tests stagnate, and eventually they start to fail. By the time anyone gives a poo poo and goes to look at the tests, they have an awful time figuring out whether the tests are invalid (not testing the right things) or evidence of a bug. Then everything gets thrown out, and a year later someone takes another stab at the whole "testing thing", with exactly the same results. Doing it right requires a culture change, plain and simple.
|
# ? Mar 7, 2015 01:26 |
|
fleshweasel posted:Get just the capture group. Groups have automatic number identifiers or can be named. Google knows. Also, write \d{4} not \d\d\d\d. Thanks, I was able to figure it out. I was using foundPAT_ID.Value which gave me everything, turns out I needed foundPAT_ID.Groups[1].Value which gave me just the group I wanted captured.
|
# ? Mar 7, 2015 03:37 |
|
Ithaqua posted:Doing it right requires a culture change, plain and simple. In other words, if you're now the "Lead Test Developer" and they want to do unit testing right, from scratch, propose this culture change as a part of your new set of responsibilities (after doing research about what exactly that entails). Don't just start being the one guy who writes unit tests. Propose the change to your entire development process that everyone needs to buy into. Might not work, but if it does you'll get some great experience and bragging rights out of it.
|
# ? Mar 7, 2015 04:51 |
|
asp.net MVC question. I want a html table with one of the columns a checkbox and then a "Delete Selected" button to post a list of things to delete. I'd post more code but I'm sure where to begin with this. Any advise on how to approach this? code:
|
# ? Mar 7, 2015 20:07 |
|
Sounds like you want to use CheckBoxList, but I've only been doing this for about 3 weeks now so there might be a better way to do it.
|
# ? Mar 7, 2015 22:13 |
|
enthe0s posted:Sounds like you want to use CheckBoxList, but I've only been doing this for about 3 weeks now so there might be a better way to do it. Thats just for webforms I think, dont think you can use them in a MVC page.
|
# ? Mar 7, 2015 22:43 |
|
bpower posted:asp.net MVC question. If you want to post to an action with a parameter like IEnumerable<Thing>, then MVC's modelbinder will read back form values with name attributes like: "[0].ThingName" "[1].ThingName" "[2].ThingName" So what you can do is: code:
code:
|
# ? Mar 8, 2015 02:57 |
|
Dreadrush posted:If you want to post to an action with a parameter like IEnumerable<Thing>, then MVC's modelbinder will read back form values with name attributes like: I don't think that's the hangup (I mean, it might be, the question is vague enough that I don't know if he understands the model binder or if he's just having trouble figuring out how to distinguish between the view and the model with his entities). bpower, I assume your html view has something like @model IEnumerable<Thing> at the top. The problem is, Thing is (presumably) an entity that you're storing in a database, and there's no place for a "user wants this deleted" field in the Things table because "being deleted" is not part of a Thing, it's just something the user wants to do to the Thing. What you want is to create a new class to use as your @model, we call this kind of class a ViewModel. C# code:
The only other sticking point here is that when you have a nested complex class like that, the @Html.DisplayNameFor helper won't work as you have it written; you will have to use an index if you want the compiler to figure it out (basically what it's doing under the hood by default as far as I know, it's just not smart enough to deal with the nested class). Like this: code:
|
# ? Mar 8, 2015 03:34 |
|
code:
|
# ? Mar 8, 2015 03:49 |
|
Ithaqua posted:Read Roy Osherove's book The Art of Unit Testing. That's first and foremost. Bingo. This is the attitude to have. Testing is something intrinsic to developing good code. Ultimately as a test lead I would hope you keep everyone else in line when it comes to testing their changes
|
# ? Mar 8, 2015 04:17 |
|
fleshweasel posted:
It bothers me a little but I don't much like underscores before variable names or putting "My" in front of everything either. Pick your poison.
|
# ? Mar 8, 2015 04:18 |
|
Che Delilas posted:It bothers me a little but I don't much like underscores before variable names or putting "My" in front of everything either. Pick your poison. _private, s_privateStatic, t_privateThreadStatic Being able to distinguish private variables with a clear underscore which separates them from parameters is great in my opinion.
|
# ? Mar 8, 2015 06:09 |
|
That doesn't solve the "property name is the same as the property type" problem though.
|
# ? Mar 8, 2015 06:18 |
|
Inverness posted:I follow the most recent guidelines here: https://github.com/dotnet/corefx/wiki/Contributing#c-coding-style OR you could just use this which has the advantage of never being misleadlingly applied. GrumpyDoctor posted:That doesn't solve the "property name is the same as the property type" problem though. That isn't a problem. They specifically designed the language to accommodate the "Color Color" problem where the most sensible name for a field is also the class name. RICHUNCLEPENNYBAGS fucked around with this message at 06:27 on Mar 8, 2015 |
# ? Mar 8, 2015 06:24 |
|
RICHUNCLEPENNYBAGS posted:That isn't a problem. They specifically designed the language to accommodate the "Color Color" problem where the most sensible name for a field is also the class name. I see a few rules codifying private fields, but no mention of public properties in that style guide (I use camel for private fields so those are never confusing). Properties are Pascal case pretty much anywhere I've ever seen, that's why it's a problem at all.
|
# ? Mar 8, 2015 07:16 |
|
Che Delilas posted:I see a few rules codifying private fields, but no mention of public properties in that style guide (I use camel for private fields so those are never confusing). Properties are Pascal case pretty much anywhere I've ever seen, that's why it's a problem at all. Huh? I said "the language," right? See here: http://blogs.msdn.com/b/ericlippert/archive/2009/07/06/color-color.aspx
|
# ? Mar 8, 2015 07:42 |
|
RICHUNCLEPENNYBAGS posted:Huh? I said "the language," right? See here: http://blogs.msdn.com/b/ericlippert/archive/2009/07/06/color-color.aspx The problem is not miscompilation, the problem is that it looks weird and is potentially confusing.
|
# ? Mar 8, 2015 08:26 |
|
GrumpyDoctor posted:The problem is not miscompilation, the problem is that it looks weird and is potentially confusing. I don't think it is, and, as evidence for the idea that this is sometimes a sensible thing to do, I'm bringing up the fact that the language designers specifically considered this scenario when designing the spec with the idea that it should be allowed.
|
# ? Mar 8, 2015 08:31 |
|
I'm not sure how to phrase my question, and google can't yet read my mind. When I run my MVC site locally, I want to use these ninject bindings. When I run it in production on azure, I want to use those bindings (which are almost the same, except for a couple different bindings). How do I detect this, and where should this conditional code go?
|
# ? Mar 8, 2015 17:11 |
|
RICHUNCLEPENNYBAGS posted:Huh? I said "the language," right? See here: http://blogs.msdn.com/b/ericlippert/archive/2009/07/06/color-color.aspx Oh whoops, conflated you and another poster.
|
# ? Mar 8, 2015 17:40 |
|
epalm posted:I'm not sure how to phrase my question, and google can't yet read my mind. Create new configuration? Like debug and release and make another Azure one that has the conditionals in it?
|
# ? Mar 8, 2015 18:50 |
|
epalm posted:I'm not sure how to phrase my question, and google can't yet read my mind. I don't know Ninject, as I've always used Unity, but I imagine the solution is pretty much the same: code:
|
# ? Mar 8, 2015 20:01 |
|
Thanks guys, will try this. Yeah, I'm using view models and passing them into the view as IEnumerable<ThingViewModel>
|
# ? Mar 8, 2015 20:08 |
|
bpower posted:Thanks guys, will try this. Yeah, I'm using view models and passing them into the view as IEnumerable<ThingViewModel> You may find your life easier if you switch to IList, because then the "smart" helpers can use the index of the current entry.
|
# ? Mar 8, 2015 22:58 |
|
GrumpyDoctor posted:That doesn't solve the "property name is the same as the property type" problem though.
|
# ? Mar 9, 2015 00:30 |
|
UberJumper posted:So apparently after writing C# unit tests for half a week. I have apparently just inherited all responsibilities as lead test developer. The company is small (~20 people), and honestly even after saying "This is a bad idea" and i don't know anything about being lead test developer, they still put me in this position. Greenfield is a lot better than undocumented brownfield so you've got that -- I would requisition a new server ( check out TeamCity if you have a budget ) and and get going there. Do you have an issue tracker? That is probably the 2nd most important thing after source control . . ..
|
# ? Mar 9, 2015 15:23 |
|
Got the check list working, thanks again guys.
|
# ? Mar 9, 2015 21:47 |
|
Is this an acceptable async pattern?C# code:
C# code:
|
# ? Mar 9, 2015 22:52 |
|
Knyteguy posted:Is this an acceptable async pattern? In general don't do this. http://www.ben-morris.com/why-you-shouldnt-create-asynchronous-wrappers-with-task-run/ Also never have an async void method unless it's an event handler.
|
# ? Mar 9, 2015 22:58 |
|
Ithaqua posted:In general don't do this. Ah, I had a feeling. Thanks for the info.
|
# ? Mar 9, 2015 23:20 |
|
UberJumper posted:So apparently after writing C# unit tests for half a week. I have apparently just inherited all responsibilities as lead test developer. The company is small (~20 people), and honestly even after saying "This is a bad idea" and i don't know anything about being lead test developer, they still put me in this position. Jenkins is really quite a simple minded piece of software and its all software configured. Find whatever plugins it needs to support C#, make sure your test harness is capable of making GBS threads out the right sort of XML (or conversely find a jenkins plugin that can handle what your test suite DOES put out) and its all kinda good from there. That said, I only know Jenkins on unix hosts so.....
|
# ? Mar 10, 2015 01:32 |
|
EF Migration questions! So many questions. In this solution, I have
FooBar uses EF 6 Code First, and contains a number of models, and a DataContext. FooBarAsp uses Microsoft's Identity framework for user authentication, and has a UserContext. Both contexts play nice and work as expected. Global.asax.cs will execute MigrateDatabaseToLatestVersion (right?). FooBar.Tests will execute DropCreateDatabaseAlways and won't care about migrations (right?). Should I EnableMigrations in FooBarAsp, or FooBar? For both contexts, or just DataContext? Edit: After running EnableMigrations in FooBar (just for kicks), my __MigrationHistory table contains two InitialCreate rows, one with ContextKey=FooBar.Models.DataContext and the other with ContextKey=FooBarAsp.Models.UserContext. So they're both being tracked already? If so, (and since I did not enable automatic migrations), do I need to explicitly run both MigrateDatabaseToLatestVersion<DataContext> and MigrateDatabaseToLatestVersion<UserContext> in Global.asax.cs? epswing fucked around with this message at 02:50 on Mar 10, 2015 |
# ? Mar 10, 2015 02:34 |
|
Your Identity Framework authentication code should be using your main data context, not a separate one. I forget what it required in detail but it was fairly trivial to do - just sticking a few interfaces on your main data context or something like that.
|
# ? Mar 10, 2015 13:16 |
|
EssOEss posted:Your Identity Framework authentication code should be using your main data context, not a separate one. I forget what it required in detail but it was fairly trivial to do - just sticking a few interfaces on your main data context or something like that. Making your DbContext inherit from IdentityContext<TUser>. As for migrations, don't turn them on until you're going into prod. The main purpose is making it easy to upgrade the application without losing any data when the new version requires schema changes.
|
# ? Mar 10, 2015 14:53 |
|
EssOEss posted:Your Identity Framework authentication code should be using your main data context, not a separate one. I forget what it required in detail but it was fairly trivial to do - just sticking a few interfaces on your main data context or something like that. This doesn't make sense to me. My application (FooBar) doesn't know or care about who is referencing it and poking it (whether that be an ASP project (FooBarAsp), or a Test project (FooBar.Tests), or a Console project). My ASP project references my class library, not the other way around. So my DataContext doesn't "know about" ASP or Identity or Sessions or Cookies. RICHUNCLEPENNYBAGS posted:Making your DbContext inherit from IdentityContext<TUser>. I'm going into prod. It's time.
|
# ? Mar 10, 2015 16:36 |
|
epalm posted:This doesn't make sense to me. My application (FooBar) doesn't know or care about who is referencing it and poking it (whether that be an ASP project (FooBarAsp), or a Test project (FooBar.Tests), or a Console project). My ASP project references my class library, not the other way around. So my DataContext doesn't "know about" ASP or Identity or Sessions or Cookies. I made table that links the ASP id to my own tables. There was no simple way around that I found, it wants a store. So my server app has an ASP identity to local id mapping table. ASP also uses GUIDS to represent IDs and my app uses integers.....
|
# ? Mar 10, 2015 21:44 |
|
If you must maintain XP compatibility and must therefore target .NET 4.0, is it a total no-brainer to grab the BCL Portability Pack to get access to async/await or are there any drawbacks to consider?
|
# ? Mar 10, 2015 22:56 |
|
epalm posted:This doesn't make sense to me. My application (FooBar) doesn't know or care about who is referencing it and poking it (whether that be an ASP project (FooBarAsp), or a Test project (FooBar.Tests), or a Console project). My ASP project references my class library, not the other way around. So my DataContext doesn't "know about" ASP or Identity or Sessions or Cookies. None of your entities hold references to users? That's kind of weird. Usually there's something (like, if you have a blog, the author of the blog is probably a user).
|
# ? Mar 11, 2015 00:09 |
|
|
# ? Jun 6, 2024 10:06 |
|
RICHUNCLEPENNYBAGS posted:None of your entities hold references to users? That's kind of weird. Usually there's something (like, if you have a blog, the author of the blog is probably a user). My Blogs have Users, sure, both of which are contained in my class library (FooBar). The stock ApplicationUser that comes with ASP is a separate entity (and separate DbContext, which happens to point to the same database). ASP's ApplicationUser and the Identity framework take care of authentication, registration, , email verification, login, logout, passwords, password strength, passwords resetting, two factor authentication, cookies, sessions, external login from sources like facebook/google, etc. FooBar doesn't know or care about any of that. FooBar's Users have a UserName, and ASP's ApplicationUsers have a UserName. When a user logs in, I just look up Foobar's User by UserName, and that's who is logged in. So when I create a new Blog, the author is FooBar's User. The end result is that FooBar is not a Web/Desktop/Console/iPhone/Android application. It's a library that any of those things can reference, interact with, and provide a user interface for. The point is that FooBar is not polluted or biased by any of those user interfaces. Edit: Note that this means I needed to add a line to Identity's AccountController.Register that creates a FooBar User with the same UserName. But that's honestly about it. epswing fucked around with this message at 01:47 on Mar 11, 2015 |
# ? Mar 11, 2015 01:31 |